共計 252 個字符,預計需要花費 1 分鐘才能閱讀完成。
在 Java 中,可以使用數組的 length 屬性來獲取數組的長度。以下是一些示例:
int[] arr = new int[5];
int length = arr.length;
System.out.println(length); // 輸出 5
String[] names = {"Alice", "Bob", "Charlie"};
int length = names.length;
System.out.println(length); // 輸出 3
注意,數組的長度是固定的,在創建數組時指定的大小不能改變。
丸趣 TV 網 – 提供最優質的資源集合!
正文完