0

Each time I run it, I get a NullPointerException.

public StrongBuilder inorder() {
    return inorder(root);

}

private StringBuilder inorder(Node root) {
    StringBuilder val;
    if (root != null) {
        inorder(root.getLeft())

    }
    val = new StringBuilder().append(root.getValue().getAccountNumber()).append(root.getValue().getName());
    inorder(root.getRight());
    return val;
}

Can anyone help spot the error for me? Thanks.

NoseKnowsAll
  • 4,593
  • 2
  • 23
  • 44
Junior M.
  • 1
  • 3

1 Answers1

0

Your problem is here:

val = new StringBuilder().append(root.getValue().getAccountNumber()).append(root.getValue().getName());

Eather this code returns null: root.getValue().getAccountNumber() Or this is the problem: root.getValue().getName() - root.getValue() returns null.

Shay
  • 497
  • 1
  • 4
  • 10