Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 7

20 Views Asked by At

why this error is occuring?

this is my array declaration : int[] mainTree = {1,2,4,-1,-1,5,-1,-1,3,-1,-1};

This array is being used to make a binary tree, and here -1 indicates a null value, but I cannot figure out why this error is being displayed.

0

There are 0 best solutions below