下面代码的输出结果是什么呢?
- class StringTest
- {
- public static void main(String[] args)
- {
- String str = "Hello";
- change(str);
- System.out.println(str);
- }
- public static void change(String str)
- {
- str += "abc";
- }
- }
- //更改为StringBuffe呢?
- class StringTest
- {
- public static void main(String[] args)
- {
- StringBuffer str = new StringBuffer("Hello");
- change(str);
- System.out.println(str);
- }
- public static void change(StringBuffer str)
- {
-
- str.append("abc");
- }
- }
复制代码
|