String s = "wangjianxin";
StringBuffer sb = new StringBuffer(s);
sb.reverse(); //反转
System.out.println(sb);
sb.replace(0,2,"1");
System.out.println(sb);
out:nixnaijgnaw
out:1xnaijgnaw
replace方法源码
public synchronized StringBuffer replace(int start, int end, String str) {
super.replace(start, end, str);
return this;
}
网友评论