获取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 红包祝福语简短10字
18 周六早晨祝福语简短