Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Comparators

The primary use of comparators is to pass them to something that does sorting, either one of the explicit sort methods, or to a data structure than implicitly sorts.

Tutorial Details:

java.util.Comparator interface
The java.util.Comparator interface can be used to create objects to pass to sort methods or sorting data structures. A Comparator must define a compare function which takes two Objects and returns a -1, 0, or 1

Comparators not needed if there's a natural sorting order
Comparators are not needed for arrays of primitive values, or arrays of collections of objects that have a natural ordering, eg, String, BigInteger, etc.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/data/collections_non_generic/comparators.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Comparators

View Tutorial:
Comparators

Related Tutorials:

Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.