- class Demo3
- {
- public static void main(String[] args)
- {
- //method_add();
- //method_delete();
- method_update();
- }
- //添加
- public static void method_add()
- {
- StringBuffer sb=new StringBuffer();
- //StringBuffer sb1=sb.append(34);
- sb.append(32).append(true).append("acd");
- sb.insert(1,"qq");
- sop(sb.toString());
- //sop(sb1.toString());
- }
- //删除
- public static void method_delete()
- {
- StringBuffer str=new StringBuffer("abcde");
- //str.delete(0,(str.length()));
- str.deleteCharAt(2);
- sop(str.toString());
- }
- //修改
- public static void method_update()
- {
- StringBuffer sb=new StringBuffer("abcdef");
- sb.replace(1,3,"java");
- sop(sb.toString());
- }
- public static void sop(String str)
- {
- System.out.println(str);
- }
- }
复制代码
|
|