索引越界:訪問了陣列中不存在的索引對應的元素,造成索引越界問題
//ArrayIndexOutOfBoundsException
空指標例外:訪問的陣列已經不再指向堆記憶體的資料,造成空指標例外
null:空值,參考資料型別的默認值,表示不指向任何有效物件
//NullPointerException
public class ArrayTest02 {
public static void main(String[] args) {
int [] arr =new int[3];
//【3】所對應的時 0 , 1 ,2 .訪問【3】時堆記憶體找不到導致報錯---//ArrayIndexOutOfBoundsException
//System.out.println(arr[3]);-------ArrayIndexOutOfBoundsException
System.out.println(arr[2]);
arr =null; //NullPointerException
System.out.println(arr[0]);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/198599.html
標籤:其他
上一篇:關于HashSet類物件使用迭代器無法進行增刪操作的問題
下一篇:約瑟夫環
