Exception in thread “main“ java.lang.ArrayIndexOutOfBoundsException: 5

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 5

insert image description here
The code is as follows:
insert image description here
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:

insert image description here
Then compile successfully!

insert image description here

Supongo que te gusta

Origin blog.csdn.net/weixin_55775980/article/details/126968838
Recomendado
Clasificación