java - interface extends comparable -


possible duplicate:
java: difference between implementing comparable , comparator?

difference between comparable interface , comparator interface , use?example?

comparable makes object intrinsically comparable other objects.

comparator allows implement external comparison logic, can applied objects not comparable, or require different logic default comparison logic.

for example, have collections.sort(list), can sort lists of objects implement comparable, while there method - collections.sort(list, comparator), can sort list.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -