码迷,mamicode.com
首页 > 其他好文 > 详细

ArrayIndexOutOfBoundsException

时间:2021-02-02 10:33:22      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:style   index   越界   out   pre   dex   color   nbsp   new   

数组角标越界异常: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");

 

ArrayIndexOutOfBoundsException

标签:style   index   越界   out   pre   dex   color   nbsp   new   

原文地址:https://www.cnblogs.com/yzyjava/p/14354355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!