1 package day04; 2 3 public class ArryExceptionDemo { 4 public static void main(String[] args) { 5 int[] arr =new int[3]; 6 System.out.println(arr[2]); 7 //空指针异常 8 arr = null;//空值 9 System.out.println(arr[0]); 10 } 11 }
执行结果: