But I am not able to get what is actual use of this in set ?
A comparator is something whose purpose is to compare two elements. It is passed to the sorted set, for cases where you want the sorted set to sort elements which are not comparable. Or if you want the elements sorted in a fashion that is different from the natural ordering provided by the comparable elements.
One part of the Java Tutorials you might do well to read is about Collections. Read it very quickly and you will forget 99% of what you read. No problem: you can always go back and read it again.
As you go through it, you will come across a section about object ordering. That tells you about Comparators.
Kishor Joshi
Ranch Hand
Posts: 674
posted 4 years ago
Thanks campbell
I will go for these links
Campbell Ritchie
Marshal
Posts: 62819
203
posted 4 years ago
You're welcome
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad: