public class Test
{
boolean getInt(int i) {
//做不到。
return true;
}

boolean getInteger(Integer i) {
int thePara=i.intValue;
                  thePara=thePara+100*11;
                  i=new Integer(thePara);
return true;
}

public static void main(String[] args) {
Test test = new Test();
int i = 0;
Integer it = new Integer(0);

test.getInt(i);
test.getInteger(it); System.out.println(i);
System.out.println(it);
}
}

解决方案 »

  1.   

    to micker(希望下一代别再贫穷), your method doesn't work.
      

  2.   

    我就是想让main中的
    System.out.println(i);
    System.out.println(it);
    两句在执行完函数调用后能输出非0值,即int i和Integer it通过函数调用被修改了。
    难道真的做不到?如果连这个都做不到,Java的参数传递机制就太成问题了。
      

  3.   

    java中根本没有指针这东西,到c++中去吧^_^
      

  4.   

    如果是在一个类里面,就直接修改
    如果在不同的类里面,将要传入并且修改的对象声明成static,应该就可以了。
      

  5.   

    public class Test
    {
             int i=0;//将变量的声明放在这里,而不是函数的内部
             Integer it=0; 
    boolean getInt(int i) {
    return true;
    }

    boolean getInteger(Integer i) {
    return true;
    }

    public static void main(String[] args) {
    Test test = new Test();
    i = 0;//将这里原来的int i的int去掉
    it = new Integer(0);

    test.getInt(i);
    test.getInteger(it); System.out.println(i);
    System.out.println(it);
    }
    }
      

  6.   

    Interge不管在那都不能改.传给函数的int在函数里被改,效果不会出此函数.
      

  7.   

    楼上的楼上的那个Integer it = 0;是无法执行的。int 是值传递在JAVA里,所以没有办法。Integer是类,但是在JAVA的API里这个类没有提供修改值的方法。也不行。不知道楼主的“先转成StringBuffer,然后处理完毕后再Integer.parseInt(str)的弱办法”是怎么实现的?用返回值的方法最简单,如果你的代码因为某些原因不能用,那应该修改,重构你的代码。