[英]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.