Add("Rick"); // Duplicate removed tset. add("Ram"); // Displaying TreeSet elements System. println("TreeSet contains: "); for(String temp : tset){ System. println(temp); } } } Output: Elements are sorted in ascending order.
TreeSet provides an implementation of the Set interface that uses a tree for storage. Objects are stored in sorted, ascending order.
Nice Information...
TreeSet provides an implementation of the Set interface that uses a tree for storage.
|
Bookmarks