package cn.itcast.day05.demo03;
/*
如何獲取數組的長度,格式:
數組名稱.length
這將會得到一個int數字,代表數組的長度。
數組一旦創建,程序運行期間,長度不可改變。
*/
public class Demo03ArrayLength {
public static void main(String[] args) {
int[] arrayA = new int[3];
int[] arrayB = {10, 20, 30, 3, 5, 4, 6, 7, 8, 8, 65, 4, 44, 6, 10, 3, 5, 4, 6, 7, 8, 8, 65, 4};
int len = arrayB.length;
System.out.println("arrayB數組的長度是:" + len);
System.out.println("=============");
int[] arrayC = new int[3];
System.out.println(arrayC.length); // 3
arrayC = new int[5];
System.out.println(arrayC.length); // 5
}
}