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:不管那些花里胡哨的东西,将方法拆开实现,简单直接.