你这个打印的还是main方法里面定义的局部变量,传递参数是不会转变参数的值的 建议楼主好好看一下canshuchu
解决方案 »
- 请教。HibernateTemplate类中,find,execute,executeFind方法的区别。
- 怎么开发浏览器插件?
- 编辑器取值问题
- action的问题!!!
- 怎么在广州找个JAVA工作那么难啊????百分散尽还复来!!(续贴)
- dwr+struts开发的带有进度条的文件上传
- 了解或使用DispatchAction类的朋友来看看了,struts-config.xml中input的缺点?
- jbuilder还是eclipse?
- 各位JAVA高手江湖救急一下呀,小弟在此跪谢了(关于连接数据库)
- 通过asix的api能捕获到接收和发送的消息吗?
- 使用java生成html树状导航
- JMX调用报错,原因不明,请高手提供思路(在线等,谢谢!)
值传递:方法调用时,实际参数把它的值传递给对应的形式参数,方法执行中形式参数值的改变不影响实际参 数的值。
引用传递:也称为传地址。方法调用时,实际参数的引用(地址,而不是参数的值)被传递给方法中相对应的形式参数,在方法执行中,对形式参数的操作实际上就是对实际参数的操作,方法执行中形式参数值的改变将会影响实际参数的值。
package test;
public class Swap { static class Integer { private int value; Integer(int value) {
this.value = value;
} public void set(int value) {
this.value = value;
} @Override
public String toString() {
return String.valueOf(value);
}
}
public static void Swapit(Integer a, Integer b) {
int temp;
temp = a.value;
a.set(b.value);
b.set(temp); } public static void main(String[] args) { Integer a = new Integer(5);
Integer b = new Integer(8);
System.out.println("交换之前:");
System.out.println("a=" + a + " b=" + b);
Swapit(a, b);
System.out.println("交换之后:");
System.out.println("a=" + a + " b=" + b); }
}运行结果:交换之前:
a=5 b=8
交换之后:
a=8 b=5