- 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
这个是因为作用域的问题吗? |