繁体   English   中英

如何检查二维数组的第二维是否为空?

[英]How do you check if the Second Dimension of a 2D array is null?

例如,假设您有一个 2D Array field[60][] 您如何检查数组的第二部分是否为空? 有没有办法做类似if(field ==null)但对于第二维的事情?

仅用于说明目的:

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");
        }

输出:

field[1] is null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM