There is always a bigger game
with one comment
This post is moved to http://ourownjava.com/java/comparable-vs-comparator-in-java
Written by cleanjava
June 21, 2011 at 11:21 pm
Posted in java, java.util
Tagged with Comparable, Comparator, java, Set, SortedSet, Sorting Elements in Java, Sorting using comparator in java, TreeSet, why Comparable ?
Subscribe to comments with RSS.
good example but primary advantage of Comparable over Comparator in Java is If any class implement Comparable interface in Java then collection of that object either List or Array can be sorted automatically by using Collections.sort() or Array.sort() method and object will be sorted based on there natural order defined by CompareTo method.
August 25, 2011 at 7:47 am
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.
Enter your email address to follow this blog and receive notifications of new posts by email.
Join 33 other followers
Blog at WordPress.com.