1.List对象中只能接收包装类
基本类型会报错
2.包装类有一些方法
如果Boolean

equals方法
比较,hashCode
3.所有包装类都可以将与之对应的基本数据类型作为参数来创建它们的实例对象
4.包含了每种基本数据类型的相关属性,如最大值、最小值、所占位数等
System.out.println(Byte.SIZE); //8
System.out.println(Short.SIZE);//16
System.out.println(Integer.SIZE);//32
System.out.println(Long.SIZE);//64
System.out.println(Float.SIZE);//32
System.out.println(Double.SIZE);//64
System.out.println(Character.SIZE);//16
//自动装箱
int m = 10;
Integer in = m;
System.out.println(in);//10
//自动拆箱
Integer inn = new Integer(10);
int n = inn;
System.out.println(n);//10
声明:以上部分代码转载自https://www.cnblogs.com/Wilange/p/7732236.html
本文详细介绍了Java中包装类的应用,包括自动装箱与拆箱的过程,以及如何利用包装类进行基本类型的比较。此外,还列举了各包装类对应的位数大小,帮助读者更好地理解其内部机制。

被折叠的 条评论
为什么被折叠?



