package squall;public class Test1 { public static void main(String[] args) { int i = new Integer(5); System.out.println(i); } }JDK1.6这样是可以过的,1.4好像不可以,1.5忘记了
誰告訴你基本類型可以new的? 、、、、
他妈有病!!!primitive可以new嘛????
貌似没见过new int 的
不可以。 但是在jdk1.5之后可以这样用 int i = new Integer(1); 因为封装类型可以自动装箱自动拆箱:)
首先明确一点,基本类型不是类。 int 是基本类型 integer 是基本类型封装类。 类可以new() 基本类型不可以new()。 有些教材说基本类型就是类是错误的。
顺便好奇一下,谁说的基本类型可以new啊喵~~``
int int1 = new int(); 这个肯定是错误的但是这个可以哦:封装类型是可以的哦!Integer int2 = new Integer();
Integer n = new Integer(0);这样都是可以哦。
Integer de = new Integer(34);
这样就可以
默认的无参构造就没有了。需要的话就必须显式声明。
{
public static void main(String[] args)
{
int i = new Integer(5);
System.out.println(i);
}
}JDK1.6这样是可以过的,1.4好像不可以,1.5忘记了
、、、、
但是在jdk1.5之后可以这样用
int i = new Integer(1);
因为封装类型可以自动装箱自动拆箱:)
int 是基本类型
integer 是基本类型封装类。
类可以new()
基本类型不可以new()。
有些教材说基本类型就是类是错误的。