In Java, the java.Lang.ArrayIndexOutOfBoundsException is a not unusual runtime exception that happens whilst an application attempts to access an array…