JAVA对象引用
- /**
- * @author 子弹哥
- *
- */
- public class TestRef {
- public static void main(String[] args) {
- StringBuffer a = new StringBuffer("a");
- StringBuffer b = new StringBuffer("b");
- append(a, b);
- System.out.println(a.toString() + "," + b.toString());
- b = a;
- System.out.println(a.toString() + "," + b.toString());
- }
- public static void append(StringBuffer a, StringBuffer b) {
- a.append(b);
- b = a;
- }
- }
大家可以探讨一下阿!
结果:
ab,b
ab,ab
ab,ab