1、添加字符
public class StringBufferDemo { public static void main(String args[])
{ StringBuffer sbf = new StringBuffer();
sbf.append("hello world");
fun(sbf);
for(int i =0; i < 100; i++)
{
sbf.append(i);
} System.out.println(sbf); } public static void fun(StringBuffer b)
{
b.append(" ").append("\r\n");
} }
2,、追加字符
public class StringBufferDemo2 { public static void main(String args[])
{
StringBuffer sbf = new StringBuffer();
sbf.append("hello world");
sbf.insert(1, "-gaga-");
sbf.insert(0, "/wiki/");
System.out.println(sbf);
} }
3,删除字符
public class StringBufferDemo3 { public static void main(String args[])
{ StringBuffer sbf = new StringBuffer();
sbf.append("omganggangstyle");
sbf.delete(0, 10);
System.out.println(sbf);
} }
4、字符反转
public class StringBufferDem4 { public static void main(String args[])
{
StringBuffer sbf = new StringBuffer();
sbf.append("hello world");
System.out.println(sbf.reverse()); } }