ArrayIndexOutOfBoundsException

时间:2021-02-02 10:33:22   收藏:0   阅读:0
数组角标越界异常:ArrayIndexOutOfBoundsException

        int[] arr = new int[]{1,2,3,4,5};
        
        情况一:
        for(int i = 0;i <= arr.length;i++){
            System.out.println(arr[i]);
        }
        情况二:
        System.out.println(arr[-2]);
        
        情况三:
        System.out.println("hello");

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!