StringBuffer修改字符串为指定格式

public static void main(String[] args) {
     StringBuffer s = new StringBuffer("123456789");
     //s.delete(0,3).replace( 1,3, "24").delete(4,6);
         
     s.delete(0,3);              //456789   删除123
     System.out.println(s);
     s.replace( 1,3, "24");      //424789   替换56为24
     System.out.println(s);
     s.delete(4,6);              //4247     删除89
     System.out.println(s);
}

PS:不管那些花里胡哨的东西,将方法拆开实现,简单直接.

往事如烟,余生有我.
原文地址:https://www.cnblogs.com/assistants/p/9524718.html