项目场景:

IntelliJ IDEA


问题描述:

控制台报错:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5 at HelloWorld.main(HelloWorld.java:14)

Exception in thread “main“ java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for lengt


原因分析:

数组下标溢出

Exception in thread “main“ java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for lengt


解决方案:

将下标改为数组定义的个数之内

Exception in thread “main“ java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for lengt

Exception in thread “main“ java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for lengt

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2022-01-13
  • 2021-09-02
  • 2021-09-27
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-08-05
  • 2021-06-20
  • 2022-12-23
  • 2021-12-27
  • 2021-12-15
  • 2022-12-23
相关资源
相似解决方案