不知道你前面的意思,:(
不过参数的传递都是传递对象的引用
所以你内部改变外部也应该改变,除非你中途变换成了另一个对象
最后是ia=null的话,ia.append的使用是非法的,有Exception的
或者编译不通过,提醒你没有初始化
不过参数的传递都是传递对象的引用
所以你内部改变外部也应该改变,除非你中途变换成了另一个对象
最后是ia=null的话,ia.append的使用是非法的,有Exception的
或者编译不通过,提醒你没有初始化
解决方案 »
- 请教:关于Jtable的问题
- 请教:如何实现鼠标向窗口内拖入一个文件,程序获得文件路径的方法
- 大家讨论一下,Iterator遍历和List遍历有什么不同,在什么情况下,使用相应的遍历?
- 请问“子窗口关闭时候,主窗口也一起关闭了“怎么解决?
- 我现在做毕业设计,题目是网络购物车.谁能帮帮我呀
- 新手求解一个有关线程同步的题!各位JAVA高手进来帮忙!
- "IT界的伟大领袖,软件天才,微软公司总设计师盖茨万岁!万万岁!"恶心!呕吐!!
- 我的applet为什么不能传进参数?
- 一个JAVA的简单问题
- 编译时如果没有程序所需的类,会出现什么“出错信息”?
- 候捷翻译的《JAVA编程思想》值得去买吗???
- 关于接口的疑问
ia.append(" ok?");改成ia=null;试试。看看两次的结果 有什么不同?
当然会改变如果要传值,使用Class.clone()
看来,传值与传址你还有点不清
ia 是一个引用(a)的副本
他与a指向同一个对象
故若你用ia.append("ok?") 是对对象的操作
但你用ia=null,是对这个引用值的操作。不会影响原对象。
根据上述现象,我理解的是ia.append()是传址,ia=null是传值,对吗?这样一来我又迷糊了。。:(
changeReference(q); // Prints 3,2,1 and modifies the Point
System.out.println(q.x); // The X coordinate of q is now 0!
When the changeReference() method is invoked, it is passed a copy of the reference held in variable q. Now both the variable q and the method parameter p hold references to the same object. The method can use its reference to change the contents of the object. Note, however, that it cannot change the contents of the variable q. In other words, the method can change the Point object beyond recognition, but it cannot change the fact that the variable q refers to that object.