Comparator interface in Java

For more information please go through http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html A comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such […]

Read More

Comparable interface in Java

For more information please go through http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html This interface imposes a natural ordering on objects of each class that implements it and the class’s compareTo method is referred to as its natural comparison method. Lists or arrays of objects that implement this interface can be sorted automatically by Collections.sort or Arrays.sort respectively. Objects that implement […]

Read More