What is wrong in my code?

import java.util.Scanner;

public class binarytree1 {

Scanner scn = new Scanner(System.in);

private class Node {
	int data;
	Node left;
	Node right;

}

private Node root;

public binarytree1(int[] pre, int[] in) {
	root = construct(pre, 0, pre.length - 1, in, 0, in.length - 1);
}

private Node construct(int[] pre, int plo, int phi, int[] in, int ilo, int ihi) {
	int si = -1;
	int nel = 0;

	// create a new node
	Node nn = new Node();
	nn.data = pre[plo];

	for (int i = ilo; i < ihi; i++) {
		if (in[i] == pre[plo]) {
			si = i;
			break;
		}
		nel++;
	}
	nn.left = construct(pre, plo + 1, plo + nel, in, ilo, si - 1);
	nn.right = construct(pre, plo + 1 + nel, phi, in, si + 1, ihi);
	return nn;

}
public int size() {
	return size(root);
}

private int size(Node node) {
	if (node==null) {
		return 0;
	}
	int ls=size(node.left);
	int rs=size(node.right);
	
	return ls+rs+1;
	
}

public boolean isbst() {
	return isbst(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

private boolean isbst(Node node, int min, int max) {
	if (node == null) {
		return true;
	}
	if (node.data > max || node.data < min) {
		return false;
	} else if (!isbst(node.left, min, node.data)) {
		return false;
	} else if (!isbst(node.right, node.data, max)) {
		return false;
	}

	return true;

}
public void printbstnodes() {
	printbstnodes(root);
}

private void printbstnodes(Node node) {
	if (node==null) {
		return;
	}
	if(isbst(node, Integer.MIN_VALUE, Integer.MAX_VALUE)) {
		System.out.println(size(node));
	}
	printbstnodes(node.left);
	printbstnodes(node.right);

	
}

public static void main(String[] args) {
	Scanner scn=new Scanner(System.in);
	int n=scn.nextInt();
	int [] preorder=new int [n];
	int [] inorder=new int [n];
	for (int i=0;i<n;i++) {
		preorder[i]=scn.nextInt();
	}
	for (int j=0;j<n;j++) {
		inorder[j]=scn.nextInt();
	}
	binarytree1 b=new binarytree1(preorder,inorder);
	b.printbstnodes();
	

}

}

you are getting ArrayIndexOutOfBoundsException for node construction for ilo and plo values

add this base case in line 23

if (ilo > ihi || plo > phi) {
return null;
}