package b.cn.itcast.autobox; import java.util.ArrayList; import java.util.List; import org.junit.Test; public class AutoBox { // 数值类 byte Byte short Short int Integer long Long double Double float // 字符 char Character 逻辑 boolean Boolean // 装箱 基本数据类型 自动--->对象类型 拆箱 @Test public void test1() { int a = 10;// 不是对象 Integer // double aa =10; // Integer a1 = 100;// 装箱 基本数据类---->对象类型 // a = a1.intValue(); // 拆箱 对象类型--->基本数据类型 // char c = new Character('a'); // Integer aa = new Integer(a); // int b = new Integer(100); List list = new ArrayList(); list.add(123.5); for (Object obj : list) { list.remove(obj); } list.add(a);// int ----> Integer new Integer(10) int aa = (Integer) list.get(0); print(10); // Double aa = 10; // 基本数据类型 int ---> double --->Integer Double } // public void print(int a) { // System.out.println("int : " + a); // double aa = 100; // // Double aaa = new Integer(100); // } public void print(Integer a) { System.out.println("Integer : " + a); // int aa = new Integer(10); } // / char c =65; A // public void print(char c) { // System.out.println("char:" + c); // } // public void print(double a) { // System.out.println("double : " + a); // } // / double public void print(Double a) { System.out.println("Double : " + a); } }