2020-02-27-Java
2020-02-27 本文已影响0人
hhp895
1.StringBuffer的api
append(Str):用于在字符串的尾部拼接一个字符串。
【append重载方法】

【案例】

deleteCharAt(index),删除指定index位置上的字符
delete(int start,int end),从什么地方删除到什么地方
【案例】

insert(int offset,Object obj)表示在指定位置,插入一个对象数据的字符串形式
【案例】

setCharAt(int index,char ch)表示在某某位置上指定一个字符
【案例】

replace(int start,int end,String s)从start位置到end位置区间,使用s替换
【案例】

reverse()逆转字符串
【案例】

trimToSize()收缩到长度所占空间
【案例】

作业:
给你一英文文章,要求对文章内容进行逆转。
例如:“hello world.” ->".world hello"-->".dlrow olleh"