//*01.
02.*程序的版权和版本声明部分
03.*Copyright(c)2017,CSDN学院
04.*All rightsreserved.
05.*文件名称:
06.*作者:郑伟哲
07.*完成日期:2018年12月23日
08.*版本号:v1.0
09.*输入描述:
10.*问题描述:数组越界的学习
11.任务和代码

/*
数组的索引编号从0开始,一直到数组的长度-1为止
如果访问数组元素的时候,索引编号并不存在,那么将会发生数组索引越界异常
ArrayIndexOutOfBoundsException
原因:索引编号写错了
解决:修改错的异常就好了
*/
public class Demo01ArrayIndex {
    public static void main(String[] args) {
        int [] array = {15,25,35};
        System.out.println(array[0]);//15
        System.out.println(array[1]);//25
        System.out.println(array[2]);//35
        System.out.println(array[3]);//越界异常
    }

}

 

运行结果

数组学习
 

知识点总结

数组的索引编号从0开始,一直到数组的长度-1为止
如果访问数组元素的时候,索引编号并不存在,那么将会发生数组索引越界异常
ArrayIndexOutOfBoundsException
原因:索引编号写错了
解决:修改错的异常就好了
心得

继续努力,虽然有点麻烦。

相关文章:

  • 2021-10-28
  • 2021-06-22
  • 2021-06-13
  • 2021-09-30
  • 2021-09-13
猜你喜欢
  • 2021-05-09
  • 2021-07-03
  • 2021-12-05
  • 2021-09-24
  • 2021-07-15
  • 2021-10-12
相关资源
相似解决方案