Hi Shravan,
A TreeSet must keep all its elements in order, but unless you specify how to order the elements, it's going to run into problems! What this means is that either
Any object you add to the TreeSet implements the Comparable interface. To implement this interface, your objects must contain a compareTo(Object o) method.Or, when you initialise your TreeSet, pass a Comparator object. This Comparator has a compare(Object o1, Object o2) method that you should override. Read more about the TreeSet on Sun's website.