在Java中获取2D数组的数组长度

在Java中获取2D数组的数组长度,第1张

在Java中获取2D数组的数组长度

考虑

public static void main(String[] args) {    int[][] foo = new int[][] {        new int[] { 1, 2, 3 },        new int[] { 1, 2, 3, 4},    };    System.out.println(foo.length); //2    System.out.println(foo[0].length); //3    System.out.println(foo[1].length); //4}

每行的列长不同。如果要通过固定大小的2D数组支持某些数据,请在包装器类中为固定值提供吸气剂。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5478025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存