java replace stringbuilder_JAVA 中Stringbuilder类的方法

展开全部

StringBuilderpublic StringBuilder() 构造一个其中不带字符的字符串生成器,初始容量为 16 个字符。62616964757a686964616fe59b9ee7ad9431333332623261 StringBuilderpublic StringBuilder(int capacity) 构造一个其中不带字符的字符串生成器,初始容量由 capacity 参数指定。 参数: capacity - 初始容量。 抛出: NegativeArraySizeException - 如果 capacity 参数小于 0。StringBuilderpublic StringBuilder(String str) 构造一个字符串生成器,并初始化为指定的字符串内容。该字符串生成器的初始容量为 16 加上字符串参数的长度。 参数: str - 缓冲区的初始内容。 抛出: NullPointerException - 如果 str 为 nullStringBuilderpublic StringBuilder(CharSequence seq) 构造一个字符串生成器,包含与指定的 CharSequence 相同的字符。该字符串生成器的初始容量为 16 加上 CharSequence 参数的长度。 参数: seq - 要复制的序列。 抛出: NullPointerException - 如果 seq 为 null方法详细信息appendpublic StringBuilder append(Object obj) Appends the string representation of the Object argument. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence. 参数: obj - an Object. 返回: a reference to this object. 另请参见: String.valueOf(java.lang.Object), append(java.lang.String)appendpublic StringBuilder append(String str) Appends the specified string to this character sequence. The characters of the String argument are appended, in order, increasing the length of this sequence by the length of the argument. If str is null, then the four characters "null" are appended. Let n be the length of this character sequence just prior to execution of the append method. Then the character at index k in the new character sequence is equal to the character at index k in the old character sequence, if k is less than n; otherwise, it is equal to the character at index k-n in the argument str. 参数: str - a string. 返回: a reference to this object.appendpublic StringBuilder append(StringBuffer sb) 将指定的 StringBuffer 添加到此序列。 按顺序将 StringBuffer 参数中的字符添加到该序列中,使该序列在长度上增加该参数的长度。如果 sb 为 null,则向该序列中添加 4 个 "null" 字符。 在执行 append 方法前,让此字符序列的长度为 n。如果 k 小于 n,则新字符序列中索引 k 处的字符等于原有序列中索引 k 处的字符;否则它等于参数 sb 中索引 k-n 处的字符。 参数: sb - 要添加的 StringBuffer。 返回: 此对象的一个引用。appendpublic StringBuilder append(CharSequence s) 从接口 Appendable 复制的描述 向此 Appendable 添加指定的字符序列。 有时可能没有添加整个序列,这取决于使用哪个类来实现字符序列 csq。例如,如果 csq 是 CharBuffer 的一个实例,则通过缓冲区的位置和限制来定义要添加的子序列。 指定者: 接口 Appendable 中的 append参数: s - 要添加的字符串序列。如果 csq 为 null,则向该 Appendable 添加四个字符 "null"。 返回: 此 Appendable 的引用 抛出: IndexOutOfBoundsExceptionappendpublic StringBuilder append(CharSequence s, int start, int end) Appends a subsequence of the specified CharSequence to this sequence. Characters of the argument s, starting at index start, are appended, in order, to the contents of this sequence up to the (exclusive) index end. The length of this sequence is increased by the value of end - start. Let n be the length of this character sequence just prior to execution of the append method. Then the character at index k in this character sequence becomes equal to the character at index k in this sequence, if k is less than n; otherwise, it is equal to the character at index k+start-n in the argument s. If s is null, then this method appends characters as if the s parameter was a sequence containing the four characters "null". 指定者: 接口 Appendable 中的 append参数: s - the sequence to append. start - the starting index of the subsequence to be appended. end - the end index of the subsequence to be appended. 返回: a reference to this object. 抛出: IndexOutOfBoundsException - if start or end are negative, or start is greater than end or end is greater than s.length()appendpublic StringBuilder append(char[] str) Appends the string representation of the char array argument to this sequence. The characters of the array argument are appended, in order, to the contents of this sequence. The length of this sequence increases by the length of the argument. The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(char[]) and the characters of that string were then appended to this character sequence. 参数: str - the characters to be appended. 返回: a reference to this object.appendpublic StringBuilder append(char[] str, int offset, int len) Appends the string representation of a subarray of the char array argument to this sequence. Characters of the char array str, starting at index offset, are appended, in order, to the contents of this sequence. The length of this sequence increases by the value of len. The overall effect is exactly as if the arguments were converted to a string by the method String.valueOf(char[],int,int) and the characters of that string were then appended to this character sequence. 参数: str - the characters to be appended. offset - the index of the first char to append. len - the number of chars to append. 返回: a reference to this object.appendpublic StringBuilder append(boolean b) Appends the string representation of the boolean argument to the sequence. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence. 参数: b - a boolean. 返回: a reference to this object. 另请参见: String.valueOf(boolean), append(java.lang.String)appendpublic StringBuilder append(char c) Appends the string representation of the char argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by 1. The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(char) and the character in that string were then appended to this character sequence. 指定者: 接口 Appendable 中的 append参数: c - a char. 返回: a reference to this object.appendpublic StringBuilder append(int i) Appends the string representation of the int argument to this sequence. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence. 参数: i - an int. 返回: a reference to this object. 另请参见: String.valueOf(int), append(java.lang.String)appendpublic StringBuilder append(long lng) Appends the string representation of the long argument to this sequence. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence. 参数: lng - a long. 返回: a reference to this object. 另请参见: String.valueOf(long), append(java.lang.String)appendpublic StringBuilder append(float f) Appends the string representation of the float argument to this sequence. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this string sequence. 参数: f - a float. 返回: a reference to this object. 另请参见: String.valueOf(float), append(java.lang.String)appendpublic StringBuilder append(double d) Appends the string representation of the double argument to this sequence. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence. 参数: d - a double. 返回: a reference to this object. 另请参见: String.valueOf(double), append(java.lang.String)appendCodePointpublic StringBuilder appendCodePoint(int codePoint) Appends the string representation of the codePoint argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by Character.charCount(codePoint). The overall effect is exactly as if the argument were converted to a char array by the method Character.toChars(int) and the character in that array were then appended to this character sequence. 参数: codePoint - a Unicode code point 返回: a reference to this object. 从以下版本开始: 1.5 deletepublic StringBuilder delete(int start, int end) Removes the characters in a substring of this sequence. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. If start is equal to end, no changes are made. 参数: start - The beginning index, inclusive. end - The ending index, exclusive. 返回: This object. 抛出: StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end.

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值