java的疑问

来源:百度知道 编辑:UC知道 时间:2024/09/23 23:40:10
application.setAttribute("count",new Integer(0));
为什么要new Integer(0)?"0"不可以吗?

setAttribute("", )
方法,第二个参数需要对象类型.
0是基本类型int的,而Integer是int的封装类.
new Integer(0);等于就是创建了一个为0的int对象.

0是整数型,是一种基本型,不是对象。