the code itself is working though whenever I try to print the results which are integers of the following form: 1 2 3 4 5 I end up with an extra whitespace after the 5, how can I delete the last whitespace while keeping the integers separated on one line
public void inorder() {
inrec(root);
}
private void inrec(BTNode<E> root) {
if (root == null) {
return;
}
inrec(root.getLeft());
System.out.printf(root.getData()+" ");
inrec(root.getRight());
}