<---------------------装箱,拆箱的过程-------------------------->

基本类型包装类:

  程序界面用户输入的数据都是以字符串类型存储的,转换成基本数据类型。

八种基本类型对应的包装类:

                  

装箱和拆箱:

public class InterDemo {
    public static void main(String[] args) {
        fun();
    }
    public static void fun(){
        //1 是基本数据类型(int 类型)   i是引用类型  ---》自动装箱
        //Integer j = new Integer(1);   装箱的过程    1.5版本之后可以省不写
        Integer i = 1;// i是引用类型  ,不能和引用类型进行运算 
        // 自动拆箱   转换成int 基本类型
          int g = i-1;
        System.out.println(g);
    }
}
原文地址:https://www.cnblogs.com/duguangming/p/10565619.html