i++行呀 我编写得测试程序,如下:已经运行成功了 public class cc { public static void main(String agrs[]) {Integer i=new Integer(1); i++; System.out.println("i="+i); } } 输出结果为:i=2;
Eclipse不行啊:ava.lang.Error: Unresolved compilation problem: Type mismatch: cannot convert from Integer to int at ClientClass.main(ClientClass.java:10) Exception in thread "main"
我在eclipse中试过的,可以改变Integer的值,我的jdk是1.5
怎么给Integer对象赋值呢?Integer里有没有现成的setXXX函数? 还是直接用=赋值?Integer n = new Integer(5); n = n+10;大家都能编译通过吗?
carylin(别信我,我在说谎) 说的很清楚了,赞一个+顶一个
i = new Integer(i.intValue()+1);
class aa{ public static void main(String[] args) { // TODO: Add your code here Integer i=new Integer(1); int a=i.intValue()+1; System.out.println (a); }
我编写得测试程序,如下:已经运行成功了
public class cc {
public static void main(String agrs[])
{Integer i=new Integer(1);
i++;
System.out.println("i="+i);
}
}
输出结果为:i=2;
Type mismatch: cannot convert from Integer to int at ClientClass.main(ClientClass.java:10)
Exception in thread "main"
还是直接用=赋值?Integer n = new Integer(5);
n = n+10;大家都能编译通过吗?
说的很清楚了,赞一个+顶一个
public static void main(String[] args) {
// TODO: Add your code here
Integer i=new Integer(1);
int a=i.intValue()+1;
System.out.println (a);
}
}//这样可以吗?