获取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 送给学长毕业祝福语简短