zoukankan      html  css  js  c++  java
  • AJPFX简述JavaStringBuffer方法

    以下是StringBuffer类支持的主要方法:

    序号 方法描述
    1 public StringBuffer append(String s)
    将指定的字符串追加到此字符序列。
    2 public StringBuffer reverse()
    将此字符序列用其反转形式取代。
    3 public delete(int start, int end)
    移除此序列的子字符串中的字符。
    4 public insert(int offset, int i)
    将 int 参数的字符串表示形式插入此序列中。
    5 replace(int start, int end, String str)
    使用给定 String 中的字符替换此序列的子字符串中的字符。

    下面的列表里的方法和String类的方法类似:

    序号 方法描述
    1 int capacity()
    返回当前容量。
    2 char charAt(int index)
    返回此序列中指定索引处的 char 值。
    3 void ensureCapacity(int minimumCapacity)
    确保容量至少等于指定的最小值。
    4 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
    将字符从此序列复制到目标字符数组 dst。
    5 int indexOf(String str)
    返回第一次出现的指定子字符串在该字符串中的索引。
    6 int indexOf(String str, int fromIndex)
    从指定的索引处开始,返回第一次出现的指定子字符串在该字符串中的索引。
    7 int lastIndexOf(String str)
    返回最右边出现的指定子字符串在此字符串中的索引。
    8 int lastIndexOf(String str, int fromIndex)
    返回最后一次出现的指定子字符串在此字符串中的索引。
    9 int length()
    返回长度(字符数)。
    10 void setCharAt(int index, char ch)
    将给定索引处的字符设置为 ch。
    11 void setLength(int newLength)
    设置字符序列的长度。
    12 CharSequence subSequence(int start, int end)
    返回一个新的字符序列,该字符序列是此序列的子序列。
    13 String substring(int start)
    返回一个新的 String,它包含此字符序列当前所包含的字符子序列。
    14 String substring(int start, int end)
    返回一个新的 String,它包含此序列当前所包含的字符子序列。
    15 String toString()
    返回此序列中数据的字符串表示形式。
  • 相关阅读:
    电商网站秒杀与抢购的系统架构[转]
    解决sublime无法安装软件的问题
    oracel中decode的使用
    使用Spring进行远程访问与Web服务[转]
    解决maven传递依赖中的版本冲突
    Linux下rz,sz
    spring bean 使用继承
    Java14-ListIterator
    Java13-Iterator的应用
    Java11-ArrayList常用的方法
  • 原文地址:https://www.cnblogs.com/AJPFX/p/10898223.html
Copyright © 2011-2022 走看看