📄 stringbuffer.html
字号:
to the current length, sufficient null characters (<code>'\u0000'</code>) are appended to the string buffer so that length becomes the <code>newLength</code> argument. <p> The <code>newLength</code> argument must be greater than or equal to <code>0</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>newLength</CODE> - the new length of the buffer.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the <code>newLength</code> argument is negative.<DT><B>See Also: </B><DD><A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="charAt(int)"><!-- --></A><H3>
charAt</H3>
<PRE>
public char <B>charAt</B>(int index)</PRE>
<DL>
<DD>The specified character of the sequence currently represented by the string buffer, as indicated by the <code>index</code> argument, is returned. The first character of a string buffer is at index <code>0</code>, the next at index <code>1</code>, and so on, for array indexing. <p> The index argument must be greater than or equal to <code>0</code>, and less than the length of this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>index</CODE> - the index of the desired character.<DT><B>Returns:</B><DD>the character at the specified index of this string buffer.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>index</code> is negative or greater than or equal to <code>length()</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getChars(int, int, char[], int)"><!-- --></A><H3>
getChars</H3>
<PRE>
public void <B>getChars</B>(int srcBegin, int srcEnd, char[] dst, int dstBegin)</PRE>
<DL>
<DD>Characters are copied from this string buffer into the destination character array <code>dst</code>. The first character to be copied is at index <code>srcBegin</code>; the last character to be copied is at index <code>srcEnd-1</code>. The total number of characters to be copied is <code>srcEnd-srcBegin</code>. The characters are copied into the subarray of <code>dst</code> starting at index <code>dstBegin</code> and ending at index: <p><blockquote><pre> dstbegin + (srcEnd-srcBegin) - 1 </pre></blockquote><DD><DL>
<DT><B>Parameters:</B><DD><CODE>srcBegin</CODE> - start copying at this offset in the string buffer.<DD><CODE>srcEnd</CODE> - stop copying at this offset in the string buffer.<DD><CODE>dst</CODE> - the array to copy the data into.<DD><CODE>dstBegin</CODE> - offset into <code>dst</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>dst</code> is <code>null</code>.<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if any of the following is true: <ul> <li><code>srcBegin</code> is negative <li><code>dstBegin</code> is negative <li>the <code>srcBegin</code> argument is greater than the <code>srcEnd</code> argument. <li><code>srcEnd</code> is greater than <code>this.length()</code>, the current length of this string buffer. <li><code>dstBegin+srcEnd-srcBegin</code> is greater than <code>dst.length</code> </ul></DL>
</DD>
</DL>
<HR>
<A NAME="setCharAt(int, char)"><!-- --></A><H3>
setCharAt</H3>
<PRE>
public void <B>setCharAt</B>(int index, char ch)</PRE>
<DL>
<DD>The character at the specified index of this string buffer is set to <code>ch</code>. The string buffer is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character <code>ch</code> at position <code>index</code>. <p> The offset argument must be greater than or equal to <code>0</code>, and less than the length of this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>index</CODE> - the index of the character to modify.<DD><CODE>ch</CODE> - the new character.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>index</code> is negative or greater than or equal to <code>length()</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="append(java.lang.Object)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</PRE>
<DL>
<DD>Appends the string representation of the <code>Object</code> argument to this string buffer. <p> The argument is converted to a string as if by the method <code>String.valueOf</code>, and the characters of that string are then appended to this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>obj</CODE> - an <code>Object</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>See Also: </B><DD><A HREF="../../java/lang/String.html#valueOf(java.lang.Object)"><CODE>String.valueOf(java.lang.Object)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>append(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="append(java.lang.String)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(<A HREF="../../java/lang/String.html">String</A> str)</PRE>
<DL>
<DD>Appends the string to this string buffer. <p> The characters of the <code>String</code> argument are appended, in order, to the contents of this string buffer, increasing the length of this string buffer by the length of the argument. If <code>str</code> is <code>null</code>, then the four characters <code>"null"</code> are appended to this string buffer. <p> Let <i>n</i> be the length of the old character sequence, the one contained in the string buffer just prior to execution of the <code>append</code> method. Then the character at index <i>k</i> in the new character sequence is equal to the character at index <i>k</i> in the old character sequence, if <i>k</i> is less than <i>n</i>; otherwise, it is equal to the character at index <i>k-n</i> in the argument <code>str</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>str</CODE> - a string.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code>.</DL>
</DD>
</DL>
<HR>
<A NAME="append(char[])"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(char[] str)</PRE>
<DL>
<DD>Appends the string representation of the <code>char</code> array argument to this string buffer. <p> The characters of the array argument are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the length of the argument. <p> The overall effect is exactly as if the argument were converted to a string by the method <A HREF="../../java/lang/String.html#valueOf(char[])"><CODE>String.valueOf(char[])</CODE></A> and the characters of that string were then <A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>appended</CODE></A> to this <code>StringBuffer</code> object.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>str</CODE> - the characters to be appended.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.</DL>
</DD>
</DL>
<HR>
<A NAME="append(char[], int, int)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(char[] str, int offset, int len)</PRE>
<DL>
<DD>Appends the string representation of a subarray of the <code>char</code> array argument to this string buffer. <p> Characters of the character array <code>str</code>, starting at index <code>offset</code>, are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the value of <code>len</code>. <p> The overall effect is exactly as if the arguments were converted to a string by the method <A HREF="../../java/lang/String.html#valueOf(char[], int, int)"><CODE>String.valueOf(char[],int,int)</CODE></A> and the characters of that string were then <A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>appended</CODE></A> to this <code>StringBuffer</code> object.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>str</CODE> - the characters to be appended.<DD><CODE>offset</CODE> - the index of the first character to append.<DD><CODE>len</CODE> - the number of characters to append.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.</DL>
</DD>
</DL>
<HR>
<A NAME="append(boolean)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(boolean b)</PRE>
<DL>
<DD>Appends the string representation of the <code>boolean</code> argument to the string buffer. <p> The argument is converted to a string as if by the method <code>String.valueOf</code>, and the characters of that string are then appended to this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>b</CODE> - a <code>boolean</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/String.html#valueOf(boolean)"><CODE>String.valueOf(boolean)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>append(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="append(char)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(char c)</PRE>
<DL>
<DD>Appends the string representation of the <code>char</code> argument to this string buffer. <p> The argument is appended to the contents of this string buffer. The length of this string buffer increases by <code>1</code>. <p> The overall effect is exactly as if the argument were converted to a string by the method <A HREF="../../java/lang/String.html#valueOf(char)"><CODE>String.valueOf(char)</CODE></A> and the character in that string were then <A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>appended</CODE></A> to this <code>StringBuffer</code> object.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>c</CODE> - a <code>char</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.</DL>
</DD>
</DL>
<HR>
<A NAME="append(int)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(int i)</PRE>
<DL>
<DD>Appends the string representation of the <code>int</code> argument to this string buffer. <p> The argument is converted to a string as if by the method <code>String.valueOf</code>, and the characters of that string are then appended to this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>i</CODE> - an <code>int</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>See Also: </B><DD><A HREF="../../java/lang/String.html#valueOf(int)"><CODE>String.valueOf(int)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>append(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="append(long)"><!-- --></A><H3>
append</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>append</B>(long l)</PRE>
<DL>
<DD>Appends the string representation of the <code>long</code> argument to this string buffer. <p> The argument is converted to a string as if by the method <code>String.valueOf</code>, and the characters of that string are then appended to this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>l</CODE> - a <code>long</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>See Also: </B><DD><A HREF="../../java/lang/String.html#valueOf(long)"><CODE>String.valueOf(long)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#append(java.lang.String)"><CODE>append(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="delete(int, int)"><!-- --></A><H3>
delete</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>delete</B>(int start, int end)</PRE>
<DL>
<DD>Removes the characters in a substring of this <code>StringBuffer</code>. The substring begins at the specified <code>start</code> and extends to the character at index <code>end - 1</code> or to the end of the <code>StringBuffer</code> if no such character exists. If <code>start</code> is equal to <code>end</code>, no changes are made.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>start</CODE> - The beginning index, inclusive.<DD><CODE>end</CODE> - The ending index, exclusive.<DT><B>Returns:</B><DD>This string buffer.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if <code>start</code> is negative, greater than <code>length()</code>, or greater than <code>end</code>.<DT><B>Since: </B><DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="deleteCharAt(int)"><!-- --></A><H3>
deleteCharAt</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>deleteCharAt</B>(int index)</PRE>
<DL>
<DD>Removes the character at the specified position in this <code>StringBuffer</code> (shortening the <code>StringBuffer</code> by one character).<DD><DL>
<DT><B>Parameters:</B><DD><CODE>index</CODE> - Index of character to remove<DT><B>Returns:</B><DD>This string buffer.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the <code>index</code> is negative or greater than or equal to <code>length()</code>.<DT><B>Since: </B><DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -