strArray[i]==null 這種情況什么時候會發生??????????
if(strArray[i]==null || "".equals(strArray[i])){
continue;
}
strArray[i]==null ?這種情況什么時候會發生??????????
if(strArray[i]==null || "".equals(strArray[i])){
continue;
}
strArray[i]==null ?這種情況什么時候會發生??????????
2015-09-18
舉報
2015-09-18
當數組存儲的是 類的對象,而不是基本數據類型時,可能發生。
因為數組在定義時,都有默認值,基本數據類型默認是“數”,比如 int[] a=new int[];a[i]默認都為0;
而引用類型(累的對象)的默認值則是null;
Student[] strArray = new Student[5];
Student t1 = new Student();
Student t2 = new Student();
Student t3 = new Student();
Student t4 = new Student();
strArray[0]=t1;
strArray[1]=t2;
strArray[2]=t3;
strArray[3]=t4;
????//這里strArray[4]沒有定義
System.out.println(strArray[4]);
????//輸出null
2016-08-22
如果是允許null,放行會怎么樣?
2015-10-09
哦哦哦哦哦哦,謝謝大哥們的 講解