JDK之AbstractStringBuilder源码解读(三)

版权声明:本文为博主原创文章,欢迎转载,转载请标明出处。 https://blog.csdn.net/qq_32523587/article/details/86432469

目录

 

append(char[] str)

append(char str[], int offset, int len)

append(boolean b)

append(char c)

append(int i)

append(long l)

delete(int start, int end)

deleteCharAt(int index)

replace(int start, int end, String str)


append(char[] str)

作用:将char[] str的内容添加到字符序列的末尾。

append(char str[], int offset, int len)

作用:将char[] str的指定位置处的内容添加到字符序列的末尾。

append(boolean b)

作用:将boolean b转换成对应的String类型("true"或"false"),然后添加到字符序列的末尾。

append(char c)

作用:将char c添加到字符序列的末尾。

append(int i)

作用:将int i添加到字符序列的末尾。

append(long l)

作用:将long l添加到字符序列的末尾。过程跟append(int i)类似,只是int改成了long,不赘述。

delete(int start, int end)

作用:删除字符序列指定位置之间的内容。

deleteCharAt(int index)

作用:删除字符序列指定位置处的内容。

replace(int start, int end, String str)

假如start、end的位置和str 的大小如下:

那么newCount的大小如下:

复制的过程如下:

作用:将字符序列中从start到end之间的内容替换成str。

猜你喜欢

转载自blog.csdn.net/qq_32523587/article/details/86432469