[英]How do you check if the Second Dimension of a 2D array is null?
Lets say for example you have a 2D Array field[60][]
.例如,假设您有一个 2D Array
field[60][]
。 How exactly can you check if the second part of the Array is null?您如何检查数组的第二部分是否为空? Is there any way to do something similiar like
if(field ==null)
but for the second dimension?有没有办法做类似
if(field ==null)
但对于第二维的事情?
Just for illustration purpose:仅用于说明目的:
Integer field[][]=new Integer[2][];
field[0]=new Integer[2]; //you can declare size for second dimension like this.
if(field[0]==null) { // do null checks
System.out.println("field[0] is null");
}if(field[1]==null) {
System.out.println("field[1] is null");
}
Output:输出:
field[1] is null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.