I\'m using Java 6.
I\'m having trouble getting my inner class to use the same generic class as its enclosing class. Currently I have
public class
I suspect what you want is something like:
class Tree {
Node head;
static class Node {
List> relatives = new ArrayList>();
T value;
}
}
Here, a tree's head node has the same T as the tree itself, and every relative node has the same T as the parent node, so all the nodes in the tree will have the same value type as the tree itself.
I used an ArrayList here because arrays cannot have generic types.