获取Java多维数组中的数组上限
为了获得多维数组的数组上限,我们使用该length()方法。对于2D数组,该length()方法返回行数。我们可以使用array_name[0].length方法访问列数。
让我们看一个程序,以使数组在Java多维数组中达到上限
示例
public class Example {
public static void main(String args[]) {
String[][] str = new String[5][10];
System.out.println("1st dimension : " + str.length); // displays the number of rows
System.out.println("2nd dimension : " + str[0].length); // displays the number of columns
}
}输出结果
1st dimension : 5 2nd dimension : 10
热门推荐
10 整形机构开业祝福语简短
11 周日徒步祝福语大全简短
12 双节祝福语简短唯美
13 女朋友考试祝福语简短
14 结婚多层蛋糕祝福语简短
15 元旦的祝福语简短 公司
16 新年稳重的祝福语简短
17 同事有趣祝福语大全简短
18 女生成年祝福语简短