日期:2014-05-18 浏览次数:20788 次
StringBuffer str = new StringBuffer("This is an apple");
int p1,p2;
char temp=' ';
p1 = p2 = str.length();
while (p1>0) {
if(temp==str.charAt(--p1)){
str.append(str.subSequence(p1+1,p2)).append(temp);
p2 = p1;
}
}
str.append(str.subSequence(p1,p2));
str.delete(0, str.length()>>1);
System.out.println(str);