📄 stringbuffer.html
字号:
<A NAME="insert(int, java.lang.Object)"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, <A HREF="../../java/lang/Object.html">Object</A> obj)</PRE>
<DL>
<DD>Inserts the string representation of the <code>Object</code> argument into this string buffer. <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 string buffer 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 string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>obj</CODE> - an <code>Object</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<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#insert(int, java.lang.String)"><CODE>insert(int, java.lang.String)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.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="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, <A HREF="../../java/lang/String.html">String</A> str)</PRE>
<DL>
<DD>Inserts the string into this string buffer. <p> The characters of the <code>String</code> argument are inserted, in order, into this string buffer at the indicated offset, moving up any characters originally above that position and 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 inserted into this string buffer. <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 string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>str</CODE> - a string.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<DT><B>See Also: </B><DD><A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="insert(int, char[])"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, char[] str)</PRE>
<DL>
<DD>Inserts the string representation of the <code>char</code> array argument into this string buffer. <p> The characters of the array argument are inserted into the contents of this string buffer at the position indicated by <code>offset</code>. 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#insert(int, java.lang.String)"><CODE>inserted</CODE></A> into this <code>StringBuffer</code> object at the position indicated by <code>offset</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>str</CODE> - a character array.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.</DL>
</DD>
</DL>
<HR>
<A NAME="insert(int, boolean)"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, boolean b)</PRE>
<DL>
<DD>Inserts the string representation of the <code>boolean</code> argument into this string buffer. <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 string buffer 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 string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>b</CODE> - a <code>boolean</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<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#insert(int, java.lang.String)"><CODE>insert(int, java.lang.String)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="insert(int, char)"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, char c)</PRE>
<DL>
<DD>Inserts the string representation of the <code>char</code> argument into this string buffer. <p> The second argument is inserted into the contents of this string buffer at the position indicated by <code>offset</code>. The length of this string buffer increases by one. <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#insert(int, java.lang.String)"><CODE>inserted</CODE></A> into this <code>StringBuffer</code> object at the position indicated by <code>offset</code>. <p> The offset argument must be greater than or equal to <code>0</code>, and less than or equal to the length of this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>c</CODE> - a <code>char</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the offset is invalid.<DT><B>See Also: </B><DD><A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="insert(int, int)"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, int i)</PRE>
<DL>
<DD>Inserts the string representation of the second <code>int</code> argument into this string buffer. <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 string buffer 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 string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>i</CODE> - an <code>int</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<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#insert(int, java.lang.String)"><CODE>insert(int, java.lang.String)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="insert(int, long)"><!-- --></A><H3>
insert</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>insert</B>(int offset, long l)</PRE>
<DL>
<DD>Inserts the string representation of the <code>long</code> argument into this string buffer. <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 string buffer at the position indicated by <code>offset</code>. <p> The offset argument must be greater than or equal to <code>0</code>, and less than or equal to the length of this string buffer.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset.<DD><CODE>l</CODE> - a <code>long</code>.<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/StringIndexOutOfBoundsException.html">StringIndexOutOfBoundsException</A></CODE> - if the offset is invalid.<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#insert(int, java.lang.String)"><CODE>insert(int, java.lang.String)</CODE></A>,
<A HREF="../../java/lang/StringBuffer.html#length()"><CODE>length()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="reverse()"><!-- --></A><H3>
reverse</H3>
<PRE>
public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>reverse</B>()</PRE>
<DL>
<DD>The character sequence contained in this string buffer is replaced by the reverse of the sequence. <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>reverse</code> method. Then the character at index <i>k</i> in the new character sequence is equal to the character at index <i>n-k-1</i> in the old character sequence.<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>StringBuffer</code> object..<DT><B>Since: </B><DD>JDK1.0.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="toString()"><!-- --></A><H3>
toString</H3>
<PRE>
public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE>
<DL>
<DD>Converts to a string representing the data in this string buffer. A new <code>String</code> object is allocated and initialized to contain the character sequence currently represented by this string buffer. This <code>String</code> is then returned. Subsequent changes to the string buffer do not affect the contents of the <code>String</code>. <p> Implementation advice: This method can be coded so as to create a new <code>String</code> object without allocating new memory to hold a copy of the character sequence. Instead, the string can share the memory used by the string buffer. Any subsequent operation that alters the content or capacity of the string buffer must then make a copy of the internal buffer at that time. This strategy is effective for reducing the amount of memory allocated by a string concatenation operation when it is implemented using a string buffer.<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a string representation of the string buffer.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/StringBuffer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<strong>MID Profile</strong></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../java/lang/String.html"><B>PREV CLASS</B></A>
<A HREF="../../java/lang/System.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="StringBuffer.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<font size="-1"><a href="mailto:midp-feedback@risc.sps.mot.com">Submit a comment or suggestion</a> Version 2.0 of MID Profile Specification<br>Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -