Is there any standard Java library class to represent a tree in Java?
Specifically I need to represent the following:
Since the question asks for an available data structure, a tree can be constructed from lists or arrays:
Object[] tree = new Object[2];
tree[0] = "Hello";
{
Object[] subtree = new Object[2];
subtree[0] = "Goodbye";
subtree[1] = "";
tree[1] = subtree;
}
instanceof
can be used to determine whether an element is a subtree or a terminal node.