如:
int i=9;
foo(i);
System.out.println(i);//Parameter i isn't 9 now
foo(i)应该怎么写,即要改变参数的值(不用返回值来获得)
java里的方法好像不能改变方法参数的值。
int i=9;
foo(i);
System.out.println(i);//Parameter i isn't 9 now
foo(i)应该怎么写,即要改变参数的值(不用返回值来获得)
java里的方法好像不能改变方法参数的值。
解决方案 »
- 给大家几个关于几何的方法,希望有用O(∩_∩)O~
- static修饰的对象在内存中的分配和单例问题
- 没有为类型 TableDemo.DataModel 定义方法 fireTableDatachanged()
- 问个java初级问题
- 关于JAVA的输入输出
- 求助:下面这个游戏用JAVA怎么编?
- 如何获取窗口的边界尺寸
- 一对一聊天程序[关于socket通信机制]
- 求助改了半天不知道什么错误(初学者一个小程序问题)~~~
- java需要什么样的操作平台?
- 如何保存 BufferedImage 中的图像到指定的路径下?
- 请大家来讨论Integer.bitCount方法为什么要这么实现!附上一个类似的方法的实现,请指正。
Integer i= new Integer(9);
foo(i);
System.out.println(i.intvalue());
int i = 9;
public void foo(int i ){ //改变的方法
this.i=i;
}
public int getI(){
return this.i;
}
public static void main(String[] args){
Test t = new Test();
t.foo(100);
System.out.println(t.getI);
}
}