.
StringBuffer 打印问题
Java代码
1.public class Test {
2.
3. public static void main(String[] args){
4.
5.
6. StringBuffer a = new StringBuffer("adc");
7. StringBuffer b = new StringBuffer("efg");
8.
9. Test test = new Test();
10. test.change(a, b);
11. System.out.println(a);
12. System.out.println(b);
13.
14.
15. }
16.
17.
18. public void change(StringBuffer a ,StringBuffer b){
19.
20.
21. a.append(b);
22. b = a;
23.
24. }
25.
26.}
Java代码
1.System.out.println(a);
2.System.out.println(b);
上面的输出结果为什么是:abcefg和efg 而不是 abcefg 和 abcefg?
|