dcsimg
Difference between Comparator and Comparable?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   arnavkumar
Posted On:   Monday, November 4, 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    More>>

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


   <<Less

Re: Difference between Comparator and Comparable?

Posted By:   rahul123  
Posted On:   Monday, December 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