stringbuilder.html

来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 1,401 行 · 第 1/5 页

HTML
1,401
字号
        int&nbsp;end,        <A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;str)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Replaces the characters in a substring of this sequence with characters in the specified <code>String</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A></CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#reverse()">reverse</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Causes this character sequence to be replaced by the reverse of the sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#setCharAt(int, char)">setCharAt</A></B>(int&nbsp;index,          char&nbsp;ch)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The character at the specified index is set to <code>ch</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#setLength(int)">setLength</A></B>(int&nbsp;newLength)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the length of the character sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A></CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#subSequence(int, int)">subSequence</A></B>(int&nbsp;start,            int&nbsp;end)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a new character sequence that is a subsequence of this sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#substring(int)">substring</A></B>(int&nbsp;start)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a new <code>String</code> that contains a subsequence of characters currently contained in this character sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#substring(int, int)">substring</A></B>(int&nbsp;start,          int&nbsp;end)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a new <code>String</code> that contains a subsequence of characters currently contained in this sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#toString()">toString</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a string representing the data in this sequence.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="StringBuilder.html#trimToSize()">trimToSize</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempts to reduce storage used for the character sequence.</TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>从类 java.lang.<A HREF="Object.html" title="java.lang 中的类">Object</A> 继承的方法</B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="Object.html#clone()">clone</A>, <A HREF="Object.html#equals(java.lang.Object)">equals</A>, <A HREF="Object.html#finalize()">finalize</A>, <A HREF="Object.html#getClass()">getClass</A>, <A HREF="Object.html#hashCode()">hashCode</A>, <A HREF="Object.html#notify()">notify</A>, <A HREF="Object.html#notifyAll()">notifyAll</A>, <A HREF="Object.html#wait()">wait</A>, <A HREF="Object.html#wait(long)">wait</A>, <A HREF="Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE>&nbsp;<A NAME="methods_inherited_from_class_java.lang.CharSequence"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>从接口 java.lang.<A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A> 继承的方法</B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="CharSequence.html#charAt(int)">charAt</A>, <A HREF="CharSequence.html#length()">length</A>, <A HREF="CharSequence.html#subSequence(int, int)">subSequence</A></CODE></TD></TR></TABLE>&nbsp;<P><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>构造方法详细信息</B></FONT></TH></TR></TABLE><A NAME="StringBuilder()"><!-- --></A><H3>StringBuilder</H3><PRE>public <B>StringBuilder</B>()</PRE><DL><DD>构造一个其中不带字符的字符串生成器,初始容量为 16 个字符。<P></DL><HR><A NAME="StringBuilder(int)"><!-- --></A><H3>StringBuilder</H3><PRE>public <B>StringBuilder</B>(int&nbsp;capacity)</PRE><DL><DD>构造一个其中不带字符的字符串生成器,初始容量由 <code>capacity</code> 参数指定。<P><DL><DT><B>参数:</B><DD><CODE>capacity</CODE> - 初始容量。<DT><B>抛出:</B><DD><CODE><A HREF="NegativeArraySizeException.html" title="java.lang 中的类">NegativeArraySizeException</A></CODE> - 如果 <code>capacity</code> 参数小于 <code>0</code>。</DL></DL><HR><A NAME="StringBuilder(java.lang.String)"><!-- --></A><H3>StringBuilder</H3><PRE>public <B>StringBuilder</B>(<A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;str)</PRE><DL><DD>构造一个字符串生成器,并初始化为指定的字符串内容。该字符串生成器的初始容量为 <code>16</code> 加上字符串参数的长度。<P><DL><DT><B>参数:</B><DD><CODE>str</CODE> - 缓冲区的初始内容。<DT><B>抛出:</B><DD><CODE><A HREF="NullPointerException.html" title="java.lang 中的类">NullPointerException</A></CODE> - 如果 <code>str</code> 为 <code>null</code></DL></DL><HR><A NAME="StringBuilder(java.lang.CharSequence)"><!-- --></A><H3>StringBuilder</H3><PRE>public <B>StringBuilder</B>(<A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A>&nbsp;seq)</PRE><DL><DD>构造一个字符串生成器,包含与指定的 <code>CharSequence</code> 相同的字符。该字符串生成器的初始容量为 <code>16</code> 加上 <code>CharSequence</code> 参数的长度。<P><DL><DT><B>参数:</B><DD><CODE>seq</CODE> - 要复制的序列。<DT><B>抛出:</B><DD><CODE><A HREF="NullPointerException.html" title="java.lang 中的类">NullPointerException</A></CODE> - 如果 <code>seq</code> 为 <code>null</code></DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>方法详细信息</B></FONT></TH></TR></TABLE><A NAME="append(java.lang.Object)"><!-- --></A><H3>append</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>append</B>(<A HREF="Object.html" title="java.lang 中的类">Object</A>&nbsp;obj)</PRE><DL><DD>Appends the string representation of the <code>Object</code>  argument. <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 sequence.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>obj</CODE> - an <code>Object</code>.<DT><B>返回:</B><DD>a reference to this object.<DT><B>另请参见:</B><DD><A HREF="String.html#valueOf(java.lang.Object)"><CODE>String.valueOf(java.lang.Object)</CODE></A>, <A HREF="StringBuilder.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="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>append</B>(<A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;str)</PRE><DL><DD>Appends the specified string to this character sequence. <p> The characters of the <code>String</code> argument are appended, in  order, 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 appended. <p> Let <i>n</i> be the length of this character sequence 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>.<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>str</CODE> - a string.<DT><B>返回:</B><DD>a reference to this object.</DL></DD></DL><HR><A NAME="append(java.lang.StringBuffer)"><!-- --></A><H3>append</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>append</B>(<A HREF="StringBuffer.html" title="java.lang 中的类">StringBuffer</A>&nbsp;sb)</PRE><DL><DD>将指定的 <tt>StringBuffer</tt> 追加到此序列。 <p>按顺序将 <tt>StringBuffer </tt>参数中的字符追加到该序列中,使该序列在长度上增加该参数的长度。如果 <tt>sb</tt> 为 <tt>null</tt>,则向该序列中追加 4 个 <tt>&quot;null&quot;</tt> 字符。 <p>在执行 <tt>append</tt> 方法前,让此字符序列的长度为 <i>n</i>。如果 <i>k</i> 小于 <i>n</i>,则新字符序列中索引 <i>k</i> 处的字符等于原有序列中索引 <i>k</i> 处的字符;否则它等于参数 <code>sb</code> 中索引 <i>k-n</i> 处的字符。<P><DD><DL></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>sb</CODE> - 要追加的 <tt>StringBuffer</tt>。<DT><B>返回:</B><DD>此对象的一个引用。</DL></DD></DL><HR><A NAME="append(java.lang.CharSequence)"><!-- --></A><H3>append</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>append</B>(<A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A>&nbsp;s)</PRE><DL><DD><B>从接口 <CODE><A HREF="Appendable.html#append(java.lang.CharSequence)">Appendable</A></CODE> 复制的描述</B></DD><DD>向此 <tt>Appendable</tt> 追加指定的字符序列。<p> 有时可能没有追加整个序列,这取决于使用哪个类来实现字符序列 <tt>csq</tt>。例如,如果 <tt>csq</tt> 是 <CODE>CharBuffer</CODE> 的一个实例,则通过缓冲区的位置和限制来定义要追加的子序列。<P><DD><DL><DT><B>指定者:</B><DD>接口 <CODE><A HREF="Appendable.html" title="java.lang 中的接口">Appendable</A></CODE> 中的 <CODE><A HREF="Appendable.html#append(java.lang.CharSequence)">append</A></CODE></DL></DD><DD><DL><DT><B>参数:</B><DD><CODE>s</CODE> - 要追加的字符串序列。如果 <tt>csq</tt> 为 <tt>null</tt>,则向该 Appendable 追加四个字符 <tt>&quot;null&quot;</tt>。<DT><B>返回:</B><DD>此 <tt>Appendable</tt> 的引用<DT><B>抛出:</B><DD><CODE><A HREF="IndexOutOfBoundsException.html" title="java.lang 中的类">IndexOutOfBoundsException</A></CODE></DL></DD></DL><HR><A NAME="append(java.lang.CharSequence, int, int)"><!-- --></A><H3>append</H3><PRE>public <A HREF="StringBuilder.html" title="java.lang 中的类">StringBuilder</A> <B>append</B>(<A HREF="CharSequence.html" title="java.lang 中的接口">CharSequence</A>&nbsp;s,                            int&nbsp;start,                            int&nbsp;end)</PRE><DL><DD>Appends a subsequence of the specified <code>CharSequence</code> to this sequence. <p> Characters of the argument <code>s</code>, starting at index <code>start</code>, are appended, in order, to the contents of this sequence up to the (exclusive) index <code>end</code>. The length of this sequence is increased by the value of <code>end - start</code>. <p> Let <i>n</i> be the length of this character sequence just prior to

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?