Is there any standard Java library class to represent a tree in Java?
Specifically I need to represent the following:
You can use TreeSet class in java.util.*. It is working like Binary search tree, so it is already sorted. TreeSet class implements Iterable, Collection and Set interfaces. You can traverse through the tree with iterator like a set.
TreeSet treeSet = new TreeSet();
Iterator it = treeSet.Iterator();
while(it.hasNext()){
...
}
You can check, Java Doc and some other .