java-Integer的自动装箱与拆箱

package com.day9.Wrapclass;

public class Demo4Integer {

  /**
  * A:案例演示
  * JDK5的新特性自动装箱和拆箱
  * Integer ii = 100;
  * ii += 200;
  * B:注意事项
  * 在使用时,Integer x = null;代码就会出现NullPointerException。
  * 建议先判断是否为null,然后再使用。

  */
  public static void main(String[] args) {
    Integer i1=100;//自动装箱,把基本数据类型转成对象
    int a=i1+100;//自动拆箱,把对象转成基本数据类型
    System.out.println(a);
  }

}

原文地址:https://www.cnblogs.com/zhujialei123/p/8138218.html