java-StringBuffer更改功能
package com.day8.StringBuffer;
public class Demo4StringBuffer {
/**
* A:StringBuffer的替换功能
* public StringBuffer replace(int start,int end,String str):
* 从start开始到end用str替换
* B:StringBuffer的反转功能
* public StringBuffer reverse():
* 字符串反转
*/
public static void main(String[] args) {
StringBuffer sb1=new StringBuffer("KobeBryant");
sb1.replace(0, 4, "KG");
System.out.println(sb1);//KGBryant
sb1.reverse();
System.out.println(sb1);//tnayrBGK
}
}