在Java中,可以使用数组的length属性来获取数组的长度。示例如下:
int[] arr = {1, 2, 3, 4, 5}; int length = arr.length; System.out.println("数组的长度为:" + length);
输出结果为:
数组的长度为:5