Arya Kumar wrote: Why TreeSet does not containe disimilar objects?
TreeSet implements NavigableSet which extends SortedSet. So TreeSet is a sorted set. So all the objects that Treeset would contain must be of comparable type. i.e. They must implement comparable interface.
Would you ever be to compare an Interger with a String? No.