stringbuilder.html
来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 1,401 行 · 第 1/5 页
HTML
1,401 行
public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>deleteCharAt</B>(int index)</PRE><DL><DD>Removes the <code>char</code> at the specified position in this sequence. This sequence is shortened by one <code>char</code>. <p>Note: If the character at the given index is a supplementary character, this method does not remove the entire character. If correct handling of supplementary characters is required, determine the number of <code>char</code>s to remove by calling <code>Character.charCount(thisSequence.codePointAt(index))</code>, where <code>thisSequence</code> is this sequence.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>index</CODE> - Index of <code>char</code> to remove<DT><B>返回:</B><DD>This object.<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if the <code>index</code> is negative or greater than or equal to <code>length()</code>.</DL></DD></DL><HR><A NAME="replace(int, int, java.lang.String)"><!-- --></A><H3>replace</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>replace</B>(int start, int end, <A HREF="String.html" title="java.lang 中的类">String</A> str)</PRE><DL><DD>Replaces the characters in a substring of this sequence with characters in the specified <code>String</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 sequence if no such character exists. First the characters in the substring are removed and then the specified <code>String</code> is inserted at <code>start</code>. (This sequence will be lengthened to accommodate the specified String if necessary.)<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>start</CODE> - The beginning index, inclusive.<DD><CODE>end</CODE> - The ending index, exclusive.<DD><CODE>str</CODE> - String that will replace previous contents.<DT><B>返回:</B><DD>This object.<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if <code>start</code> is negative, greater than <code>length()</code>, or greater than <code>end</code>.</DL></DD></DL><HR><A NAME="insert(int, char[], int, int)"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int index, char[] str, int offset, int len)</PRE><DL><DD>Inserts the string representation of a subarray of the <code>str</code> array argument into this sequence. The subarray begins at the specified <code>offset</code> and extends <code>len</code> <code>char</code>s. The characters of the subarray are inserted into this sequence at the position indicated by <code>index</code>. The length of this sequence increases by <code>len</code> <code>char</code>s.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>index</CODE> - position at which to insert subarray.<DD><CODE>str</CODE> - A <code>char</code> array.<DD><CODE>offset</CODE> - the index of the first <code>char</code> in subarray to be inserted.<DD><CODE>len</CODE> - the number of <code>char</code>s in the subarray to be inserted.<DT><B>返回:</B><DD>This object<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if <code>index</code> is negative or greater than <code>length()</code>, or <code>offset</code> or <code>len</code> are negative, or <code>(offset+len)</code> is greater than <code>str.length</code>.</DL></DD></DL><HR><A NAME="insert(int, java.lang.Object)"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int offset, <A HREF="Object.html" title="java.lang 中的类">Object</A> obj)</PRE><DL><DD>Inserts the string representation of the <code>Object</code> argument into this character sequence. <p> The second argument is converted to a string as if by the method <code>String.valueOf</code>, and the characters of that string are then inserted into this sequence at the indicated offset. <p> The offset argument must be greater than or equal to <code>0</code>, and less than or equal to the length of this sequence.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>obj</CODE> - an <code>Object</code>.<DT><B>返回:</B><DD>a reference to this object.<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<DT><B>另请参见:</B><DD><A HREF="String.html#valueOf(java.lang.Object)"><CODE>String.valueOf(java.lang.Object)</CODE></A>, <A HREF="StringBuilder.html#insert(int, java.lang.String)"><CODE>insert(int, java.lang.String)</CODE></A>, <A HREF="StringBuilder.html#length()"><CODE>length()</CODE></A></DL></DD></DL><HR><A NAME="insert(int, java.lang.String)"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int offset, <A HREF="String.html" title="java.lang 中的类">String</A> str)</PRE><DL><DD>Inserts the string into this character sequence. <p> The characters of the <code>String</code> argument are inserted, in order, into this sequence at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument. If <code>str</code> is <code>null</code>, then the four characters <code>"null"</code> are inserted into this sequence. <p> The character at index <i>k</i> in the new character sequence is equal to: <ul> <li>the character at index <i>k</i> in the old character sequence, if <i>k</i> is less than <code>offset</code> <li>the character at index <i>k</i><code>-offset</code> in the argument <code>str</code>, if <i>k</i> is not less than <code>offset</code> but is less than <code>offset+str.length()</code> <li>the character at index <i>k</i><code>-str.length()</code> in the old character sequence, if <i>k</i> is not less than <code>offset+str.length()</code> </ul><p> The offset argument must be greater than or equal to <code>0</code>, and less than or equal to the length of this sequence.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>str</CODE> - a string.<DT><B>返回:</B><DD>a reference to this object.<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<DT><B>另请参见:</B><DD><A HREF="StringBuilder.html#length()"><CODE>length()</CODE></A></DL></DD></DL><HR><A NAME="insert(int, char[])"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int offset, char[] str)</PRE><DL><DD>Inserts the string representation of the <code>char</code> array argument into this sequence. <p> The characters of the array argument are inserted into the contents of this sequence at the position indicated by <code>offset</code>. The length of this sequence 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="String.html#valueOf(char[])"><CODE>String.valueOf(char[])</CODE></A> and the characters of that string were then <A HREF="StringBuilder.html#insert(int, java.lang.String)"><CODE>inserted</CODE></A> into this character sequence at the position indicated by <code>offset</code>.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>str</CODE> - a character array.<DT><B>返回:</B><DD>a reference to this object.<DT><B>抛出:</B><DD><CODE><A HREF="StringIndexOutOfBoundsException.html" title="java.lang 中的类">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.</DL></DD></DL><HR><A NAME="insert(int, java.lang.CharSequence)"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int dstOffset, <A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A> s)</PRE><DL><DD>Inserts the specified <code>CharSequence</code> into this sequence. <p> The characters of the <code>CharSequence</code> argument are inserted, in order, into this sequence at the indicated offset, moving up any characters originally above that position and increasing the length of this sequence by the length of the argument s. <p> The result of this method is exactly the same as if it were an invocation of this object's insert(dstOffset, s, 0, s.length()) method. <p>If <code>s</code> is <code>null</code>, then the four characters <code>"null"</code> are inserted into this sequence.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>dstOffset</CODE> - the offset.<DD><CODE>s</CODE> - the sequence to be inserted<DT><B>返回:</B><DD>a reference to this object.<DT><B>抛出:</B><DD><CODE><A HREF="IndexOutOfBoundsException.html" title="java.lang 中的类">IndexOutOfBoundsException</A></CODE> - if the offset is invalid.</DL></DD></DL><HR><A NAME="insert(int, java.lang.CharSequence, int, int)"><!-- --></A><H3>insert</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>insert</B>(int dstOffset, <A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A> s, int start, int end)</PRE><DL><DD>Inserts a subsequence of the specified <code>CharSequence</code> into this sequence. <p> The subsequence of the argument <code>s</code> specified by <code>start</code> and <code>end</code> are inserted, in order, into this sequence at the specified destination offset, moving up any characters originally above that position. The length of this sequence is increased by <code>end - start</code>. <p> The character at index <i>k</i> in this sequence becomes equal to: <ul> <li>the character at index <i>k</i> in this sequence, if <i>k</i> is less than <code>dstOffset</code> <li>the character at index <i>k</i><code>+start-dstOffset</code> in the argument <code>s</code>, if <i>k</i> is greater than or equal to <code>dstOffset</code> but is less than <code>dstOffset+end-start</code> <li>the character at index <i>k</i><code>-(end-start)</code> in this sequence, if <i>k</i> is greater than or equal to <code>dstOffset+end-start</code> </ul><p> The dstOffset argument must be greater than or equal to <code>0</code>, and less than or equal to the length of this sequence. <p>The start argument must be nonnegative, and not greater than <code>end</code>. <p>The end argument must be greater than or equal to <code>start</code>, and less than or equal to the length of s. <p>If <code>s</code> is <code>null</code>, then this method inserts characters as if the s parameter was a sequence containing the four characters <code>"null"</code>.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>dstOffset</CODE> - the offset in this sequence.<DD><CODE>s</CODE> - the sequence to be inserted.<DD><CODE>start</CODE> - the starting index of the subsequence to be inserted.<DD><CODE>end</CODE> - the end index of the subsequence to be inserted.<DT><B>返回:</B><DD>a reference to this object.<DT><B>抛出:</B><DD><CODE><A HR
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?