Whenever I run this method the print goes perfectly fine so the argument is passed and not null. Still it gives a NullPointerException when the argument is added to the children ArrayList (which is a part of the class). Why is this?
public void addChild(_Node n){
System.out.println("Add " + n.getClass().getSimpleName() + " to " + this.getClass().getSimpleName());
children.add(n);
}
Check to see if
childrenhas been instantiated correctly. This is a common mistake beginners make.