package jave;
/*String类的字符串是不可变的,而用StringBuffer可转换成可变的字符串*/
public class stringBuffer {
public static void main(String[] args) {
String s = "Mircosoft";
char[] a = {'a', 'b', 'c'};
StringBuffer sb1 = new StringBuffer(s);//转变成可变的字符串
sb1.append('/').append("IBM").append('/').append("Sun");//在sb1末尾依次添加
System.out.println(sb1);
StringBuffer sb2 = new StringBuffer("数字");
for(int i = 0; i <= 9; i++) {
sb2.append(i);
}
System.out.println(sb2);
sb2.delete(8, sb2.length()).insert(0, a);//删除从第8位到sb2.length的一串字符,并在位置0插入字符数组a
System.out.println(sb2);
System.out.println(sb2.reverse());//逆序输出sb2
}
}