StringBuffer类

字符串一般用String类型表示

但是String常量 一旦声明不可改变

如果需要频繁修改字符串 需要使用StringBuffer类

以下为StringBuffer代码

public static void main(String[] args) throws Exception{
    StringBuffer buf = new StringBuffer();
    buf.append(“HEllo”).append("MLDN").append("!!");
    change(buf);
    System.out.print(buf);
}
public static void change(StringBuffer temp){
    temp.append("/n").append("hello");
}

posted @ 2018-01-08 17:33  你可别玩了  阅读(102)  评论(0编辑  收藏  举报