Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 5
The code is as follows:
Reason:
Determine the critical value of the array, don't think that ++, or –, or some other mistakes lead to such low-level errors as out of bounds.
The subscript access operation cannot exceed the valid range [0, length - 1]. If it exceeds the valid range, a subscript out of bounds exception will occur.
Revise:
Then compile successfully!