This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Your original code will run with the above change. The rule being simple. If you want to sort using a comparator then you need to pass the comparator in the TreeSet's constructor. Otherwise by default TreeSet assumes that the objects in the Set implement the Comparable interface.
Joined: Sep 13, 2008
Yes. I got it.. Thanks Wouter,Santiago and Harvinder !!!