[英]How to Initialize 2d ArrayList with 0 in one line
How to Initialize all the element of 2d Array List in Java with 0 in single line of code without using for lop.如何在不使用 for lop 的情况下用单行代码将 Java 中二维数组列表的所有元素初始化为 0。
ArrayList of m rows and n columns. ArrayList,共 m 行 n 列。
How to initialise value of all the elements to 0 at the time of defining it.如何在定义时将所有元素的值初始化为0。
Not sure what you meant by 2D ArrayList, but you returned type of List
instead of ArrayList
with help of below:不确定 2D ArrayList 是什么意思,但是您在以下帮助下返回了
List
类型而不是ArrayList
:
List<List<Integer>> a=Arrays.asList(Arrays.asList(0));
For normal arrays
you can do something:对于正常
arrays
你可以做一些事情:
int[][] b=new int[1][2];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.