Difference between Comparator and Comparable?
1 posts in topic
Thread View Thread View

Difference between Comparator and Comparable?...
Mon Nov 04, 2013 10:49 PM

Can one help me in comparable and comparator methods in Java Collections. I am not able to find the difference between these two. How do these methods work internally?
Thanks in advance

 Comparable work on default natural sorting order&n...

Mon Dec 16, 2013 09:37 PM

Comparable work on default natural sorting order 
comparator work on customize sorting order

comparable present in java.lang package and it contain only one method
compareTo(Object obj)
comarator present in java.util package and it contain two method
compare() and equals method

All wrapper class & string class implements comparable interface.
only implements class on comparator are Collator & RuleBasedCollator

About | Sitemap | Contact