2007.10.24
学习IBM网站上的技术文章收获
1.集合中不能包含基本类型,若要使用基本类型,必须先用对应的基本类型的包装类型包装下(这正是包装类的作用)
例如,要将一个 int
基本类型放到 ArrayList
中,我们必须使用像下面这样的代码:
附:
Integer boxedInt = new Integer(1);
someArrayList.add(boxedInt);
Boolean
用于boolean
类型。Byte
用于byte
类型。Character
用于char
类型。Integer
用于int
类型。Short
用于short
类型。Long
用于long
类型。Float
用于float
类型。Double
用于double
类型。