Java 自动拆箱

  public static void main(String[] args) {
        UnBoxing();
    }

    public static Long getLong(){
        Long a=null;
        return a;
    }

    public static void UnBoxing(){
        // 自动拆箱,由于a为Null
    // 会调用Integer.intValue方法自动拆箱包装器类型为基本数据类型。
        long b=getLong();// 出现 NullPointerException
        System.out.println(b);
    }
原文地址:https://www.cnblogs.com/web1992/p/4819199.html