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);
    }

 

相关文章:

  • 2021-10-26
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-11
  • 2021-07-24
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2021-05-17
  • 2021-11-22
  • 2021-07-20
  • 2021-10-14
  • 2021-11-29
相关资源
相似解决方案