Joh*_*ohn 5 java autoboxing
有人可以向我解释使用Integer,Boolean等代替JAVA中的原始类型吗?
我似乎无法掌握他们提供的优势.它们似乎会产生处理空值的不必要问题.
谢谢!
tan*_*ens 8
Boolean,Integer,Long,...是对象.您可以在不能使用原始类型的地方使用它们,例如
Boolean
Integer
Long
Map
null
Number
例子:
new ArrayList<Integer>(); Long id = null; Number num = new Long( 3 );
归档时间:
16 年,4 月 前
查看次数:
3020 次
最近记录: