Why does this line of code in my Tree class not work. I get an error on the add(child).
public void addChild(TreeNode<T> parent, TreeNode<T> child)
{
parent.children.add(child);
}
Here is TreeNode
public class TreeNode<E> {
protected int accountNum;
protected ArrayList<E> children;
That’s because children is an
ArrayListofE, not ofTreeNode<E>, while child is aTreeNode<E>.Depends on your needs, it could be either:
Or: