我现在有个变量:
Integer i = new Integer(1);现在我想让i的值加一,如何实现?“i++”好像不行吧,那怎么办呢?

解决方案 »

  1.   

    Integer类里,我只找到一堆getXXX,没有setXXX啊如何给Integer对象赋值呢?
      

  2.   

    i++行呀
    我编写得测试程序,如下:已经运行成功了
    public class cc {
       public static void main(String agrs[])
       {Integer i=new Integer(1);
        i++;
        System.out.println("i="+i);
       }
    }
    输出结果为:i=2;
      

  3.   

    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"
      

  4.   

    我在eclipse中试过的,可以改变Integer的值,我的jdk是1.5
      

  5.   

    怎么给Integer对象赋值呢?Integer里有没有现成的setXXX函数?
    还是直接用=赋值?Integer n = new Integer(5);
    n = n+10;大家都能编译通过吗?
      

  6.   

    carylin(别信我,我在说谎)
    说的很清楚了,赞一个+顶一个
      

  7.   

    i = new Integer(i.intValue()+1);
      

  8.   

    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);
    }

    }//这样可以吗?