MyArray.length - 1
is the last element of the array. The biggest value of i
which will go down in the if
is MyArray.length - 1
. And you increase it by one in i + 1
, so you get MyArray.length
. Of course you will receive an exception:)
More Related Contents:
- ArrayOutOfBoundsException Error?
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- java.lang.ArrayIndexOutOfBoundsException: 0
- JAVA ArrayIndexoutofBoundException issue
- Write a program that takes an array/arraylist of integer and finds longest sub array/arraylist whose entries are equal [closed]
- Difference between int[] array and int array[]
- How to split a String by space
- The case against checked exceptions
- NullPointerException when Creating an Array of objects [duplicate]
- How do I copy a 2 Dimensional array in Java?
- How to convert object array to string array in Java
- How to return an array from JNI to Java?
- Scanner NoSuchElementException
- How do I fill arrays in Java?
- Java: Global Exception Handler
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Difference between Unchecked exception or runtime exception
- method called after release() exception unable to resume with android camera
- Guidelines on Exception propagation (in Java)
- Convert LocalDate in DD/MM/YYYY LocalDate [duplicate]
- Why can I edit the contents of a final array in Java?
- How to manipulate arrays. Find the average. Beginner Java
- Time Complexity for Java ArrayList
- How to deep copy an irregular 2D array
- What is the use of printStackTrace() method in Java?
- java: Arrays.sort() with lambda expression
- Print the stack trace of an exception
- Try-catch-finally and then again a try catch
- problems with java3D lib configuration
- Java generics and array initialization