This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Have you looked at the Comparator javadoc?
Have you search for something like "java comparator tutorial"?
Because then you would have found this java.sun.com tutorial.
But to answer one of your questions. No you don't have to create a comparator for every column. Just for each object that you want to compare.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joined: Dec 10, 2009
Yes I have looked at the java sun tutorial. Maybe I didnt make myself quite clear in my orignal post.
In the examples I have seen so far when comparing objects, it seems that each comparator can only compare 1 field of the objects at a time.
I would like to have 1 comparator for each object that can compare any of the all of the fields of that object.
As an example from this website: comparator example, they have 2 comparators 1 for age and 1 for name. can I have 1 comparator to handle both??