http://www.springsource.org/download ( for all spring components )
http://xfire.codehaus.org/Download ( for xfire components )
http://www.quartz-scheduler.org/download/ ( for running async jobs)
java.util.Collections.sort(listOfCountryNames, Collator.getInstance());
Collection<String> countryNames =new TreeSet<String>(Collator.getInstance());countryNames.add("UK");countryNames.add("Germany");countryNames.add("Australia");// Tada... sorted.
TreeSet countyNames and instantly knows: this is a sorted collection of Strings without duplicates, and I can be sure that this is true at every moment. So much information in a short declaration.
accepted
|
Il allows you to pass an instance of Comparator to sort according to your needs. Note that thejavadoc of Comparator contains guidelines regarding the building of comparators.
You may define the comparator as an anonymous class if it's only locally used. Here's an example where I sort objects regarding to one of their fields which is a String :
Alternatively, you might also make your class implement the Comparable interface but this makes sense only if you can define a natural (obvious) order.
I would create an inner class implementing the Comparator interface:
Now when you want to sort your Car list by horsePower:
|