java笔试陷阱:对象引用作为参数传递时陷阱
2014-04-19 20:46
267 查看
public class Test5 { public static void main (String args[]) { Test5 test=new Test5(); test.method(); } public void method() { int i=5; May may=new May(); may.i=25; this.testMethod(may,i); System.out.println(may.i);//20一定要将指向关系的示意图画出来,清晰明了! } public void testMethod(May may,int i) { i=0; may.i=20; May be=new May(); may=be; System.out.println(may.i+" "+i);//输出15 0 } } class May { public int i=15; }
相关文章推荐
- 学习android JNI的那些事儿--------6. 在java中传入引用数据类型(对象)作为参数
- Java 把对象作为参数传到一个方法里,这个是值传递还是引用传递, 为什么结果这么怪?
- 【java】值传递和引用传递---对象作为方法的参数传入属于哪种传递
- java中要注意对象作为参数引用返回时,对象本身是否变化了
- 关于Java对象作为参数传递是传值还是传引用的问题
- 【Java基础】基本类型的包装类作为参数传递是值传递还是引用传递
- java (值传递和引用传递) String 和StringBuffer 作为参数传递
- Java传递基本类型:值传递,对象作为参数:引用传递
- java中对象引用,特别作为参数时候注意事项
- JAVA对象与引用、JAVA参数传递~~~转自百度文档,绕了我很久的问题终于搞明白了
- Java对对象的引用(强,软,弱,虚)
- Java对象内存存储,引用传递,值传递详细图解
- JAVA 对象引用,以及对象赋值
- Java多态性详解——父类引用子类对象
- “吃人”的那些Java名词:对象、引用、堆、栈
- Java对象的生命周期与垃圾回收以及四种引用
- java参数传递(值传递还是引用传递)
- java String对象是“引用”传递的
- java能像JavaScript那样,直接对基本类型的数据,像对待对应的对象那样,引用相应对象里的属性吗?
- 【JSF心得】JAVA的对象传递是引用传递