Pour trier des objets, Java doit savoir comment les comparer. Il existe deux mécanismes : Comparable — l'objet sait se comparer à un autre (ordre naturel) ; Comparateur : un objet distinct définit une règle de comparaison (ordre personnalisé).

L'interface comparable<T>
Full content is available with a subscription.
Get full access to all courses on the platform for one year with a single payment.
Unlike other platforms that charge per course, here you get everything for one price, and after one year of use there will be no automatic charge for the following year.