所谓自动装箱就是将基本数据类型转换为包装类,自动拆箱则是将包装类转换为基本数据类型。
如Integer a=3;这段代码的执行就是自动装箱的过程,其中调用了Integer.ValueOf(int i)方法。而在Integer a=new Integer(3); int b=a;中int b=a的执行就是自动拆箱的过程,其中调用了int a=b.intValue()方法。
以下是关于自动装箱与拆箱的特性进行实验的例子
System.out.println(cd);
Integer e=129;
Integer f=129;
System.out.println(gh);
System.out.println("=");
Double i=5.0;
Double j=5.0;
System.out.println(ij);
System.out.println("=");
Long k=126L;
Long l=63L;
System.out.println(c(a+b));
System.out.println(k.equals(a+l));
}
}



