java例程练习(StringBuffer类)

public class TestBuffer {//StringBuffer存储变长的字符序列 ,String类是不可变长的字符序列
	public static void main(String[] args) {
		String s = "Mircosoft";
		char [] c = {'a', 'b', 'c'};
		StringBuffer sb1 = new StringBuffer(s);
		sb1.append('/').append("IBM").append('/').append("Sun");
		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, c);
		System.out.println(sb2);
		System.out.println(sb2.reverse());
	}
}

你可能感兴趣的:(java,String,IBM,存储,Class,sun)