ArrayIndexOutOfBoundsException super classes are Exception RutimeExcepion and
IndexOutOfBoundsException.
The ArrayIndexOutOfBoundsException is thrown when an index is passed to an array
which doesn’t contain an element at that particular index location.
ArrayIndexOutOfBoundsException is thrown to indicate that we are trying to
access array element with an illegal index. This exception is thrown when the index is either negative or greater than or equal to the size of the array.
When Should You Use It?
Since Java has internal classes and object structures to manage Arrays — and because said objects will produce errors like the java.lang.ArrayIndexOutOfBoundsException on their own — there will rarely be a situation where you’ll need to explicitly throw your own ArrayIndexOutOfBoundsException. For example, if you were creating your own data structure object that contained a non-array collection of elements, you’d likely want to explicitly throw a java.lang.IndexOutOfBoundsException, as opposed to a java.lang.ArrayIndexOutOfBoundsException, since the JVM will handle that for you most of the time.