public class Test {
public static void main(String args[]){
TestStringBuffer tsb = new TestStringBuffer();
String s= new String("abc");
tsb.setAsb(s);
System.out.println(tsb.getAsb());
}
}
class TestStringBuffer{
private StringBuffer sb;
public TestStringBuffer(){
this.sb = new StringBuffer("数据");
}
public String getAsb() {
return this.sb.toString();
}
public void setAsb(String s){
this.sb.append(s);
}
------解决方案-------------------- 没有这种情况的吧
Java code
public class Test
{
public static void main(String[] args) throws Exception
{
StringBuffer str1 = new StringBuffer("aaa");
String str2 = "bbb";
str1.append(str2);
System.out.println(str1.toString());
}
}