public class StringBufferDemo { public static void main(String[] args) { StringBuffer sb1 = new StringBuffer("hello"); StringBuffer sb2 = new StringBuffer("world"); System.out.println(sb1 + "---" + sb2); change(sb1, sb2); System.out.println(sb1 + "---" + sb2); } public static void change(StringBuffer sb1, StringBuffer sb2){ sb1 = sb2; sb2.append(sb1); }
|