获取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 好听的元旦简短祝福语