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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -