day05-数组的异常_索引越界异常

This commit is contained in:
2026-01-17 10:16:20 +08:00
parent c963da2b2a
commit 70899762d9

View File

@@ -0,0 +1,20 @@
package com.inmind.array01;
/*
数组的异常_角标越界异常
ArrayIndexOutOfBoundsException:
数组 索引 越界 异常
注意:数组中长度是固定的,数组的最大索引值,数组长度-1,数组.length - 1就是最大门牌号
0-数组.length - 1的门牌才能正确操作数组否则ArrayIndexOutOfBoundsException
*/
public class Demo03 {
public static void main(String[] args) {
double[] arr = new double[3];
System.out.println(arr);//地址
System.out.println(arr[0]);//0.0
System.out.println(arr[1]);
System.out.println(arr[2]);
System.out.println(arr[3]);
System.out.println(arr[4]);
}
}