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
  }

}

posted @ 2017-12-27 16:24  简简单单zjl  阅读(1243)  评论(0编辑  收藏  举报