数组空指针异常

 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 }

执行结果:

posted @ 2020-12-30 19:49  Eleanor123  阅读(71)  评论(0编辑  收藏  举报