day05-数组的异常_索引越界异常
This commit is contained in:
20
day05/src/com/inmind/array01/Demo03.java
Normal file
20
day05/src/com/inmind/array01/Demo03.java
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user