java:StringBuffer字符处理对象

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()); } }

  

上一篇:iOS开发之iOS程序的启动过程


下一篇:cxGrid常用属性设置