查找所有数组多维数组的长度,Java [英] Finding length of all arrays multidimensional array, Java

查看:117
本文介绍了查找所有数组多维数组的长度,Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用多维数组来存储数据网格。但是,我还没有找到一种简单的方法来查找数组 2nd 部分的长度。例如:

I would like to use a multidimensional array to store a grid of data. However, I have not found a simple way to find the length of the 2nd part of the array. For example:

boolean[][] array = new boolean[3][5];
System.out.println(array.length);

仅输出 3

是否有另一个简单的命令来查找第二个数组的长度? (即以相同的方式输出5)

Is there another simple command to find the length of the second array? (i.e. output 5 in the same manner)

推荐答案

尝试使用 array [0] .length ,这将给出你正在寻找的尺寸(因为你的数组没有锯齿状)。

Try using array[0].length, this will give the dimension you're looking for (since your array is not jagged).

这篇关于查找所有数组多维数组的长度,Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆