⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javalang.doc11.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 4 页
字号:
Examples:<p>
<pre><br><a name="25372"></a>"hamburger".substring(4, 8) returns "urge"
<br><a name="25378"></a>"smiles".substring(1, 5) returns "mile"
</pre><a name="14008"></a>
<p><font size=+1><strong>20.12.33   </strong> <code>public String <code><b>concat</b></code>(String str)<br>throws NullPointerException</code></font>
<p>
<a name="4689"></a>
If the length of the argument string is zero, then a reference to this <code>String</code> object 
is returned. Otherwise, a new <code>String</code> object is created, representing a character 
sequence that is the concatenation of the character sequence represented by this 
<code>String</code> object and the character sequence represented by the argument string.
<p><a name="25355"></a>
Examples:<p>
<pre><a name="25357"></a>
"cares".concat("s") returns "caress"
<a name="25356"></a>"to".concat("get").concat("her") returns "together"
</pre><a name="31327"></a>
If <code>str</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.
<p><a name="14009"></a>
<p><font size=+1><strong>20.12.34   </strong> <code>public String <code><b>replace</b></code>(char oldChar, char newChar)</code></font>
<p>
<a name="30707"></a>
If the character <code>oldChar</code> does not occur in the character sequence represented by 
this <code>String</code> object, then a reference to this <code>String</code> object is returned. Otherwise, 
a new <code>String</code> object is created that represents a character sequence identical to 
the character sequence represented by this <code>String</code> object, except that every occurrence
of <code>oldChar</code> is replaced by an occurrence of <code>newChar</code>.
<p><a name="30710"></a>
Examples:<p>
<pre><a name="30721"></a>
"mesquite in your cellar".replace('e', 'o')
<a name="30722"></a>					returns "mosquito in your collar"
<a name="30724"></a>"the war of baronets".replace('r', 'y')
<a name="30725"></a>					returns "the way of bayonets"
<a name="30727"></a>"sparring with a purple porpoise".replace('p', 't')
<a name="30728"></a>					returns "starring with a turtle tortoise"
<a name="30712"></a>"JonL".replace('q', 'x') returns "JonL" (no change)
</pre><a name="30708"></a>
<p><font size=+1><strong>20.12.35   </strong> <code>public String <code><b>toLowerCase</b></code>()</code></font>
<p>
<a name="4708"></a>
If this <code>String</code> object does not contain any character that is mapped to a different 
character by the method <code>Character.toLowerCase</code> <a href="javalang.doc4.html#20313">(&#167;20.5.20)</a>, then a reference 
to this <code>String</code> object is returned. Otherwise, this method creates a new <code>String</code> 
object that represents a character sequence identical in length to the character 
sequence represented by this <code>String</code> object, with every character equal to the 
result of applying the method <code>Character.toLowerCase</code> to the corresponding 
character of this <code>String</code> object.
<p><a name="25399"></a>
Examples:<p>
<pre><a name="25400"></a>
"French Fries".toLowerCase() returns "french fries"
<a name="25405"></a>"<img src="chars/capiota.gif"><img src="chars/capchi.gif"><img src="chars/captheta.gif"><img src="chars/capupsil.gif"><img src="chars/capsigma.gif">".toLowerCase() returns "<img src="chars/iota.gif"><img src="chars/chi.gif"><img src="chars/theta.gif"><img src="chars/upsilon.gif"><img src="chars/sigma1.gif">"
</pre><a name="14011"></a>
<p><font size=+1><strong>20.12.36   </strong> <code>public String <code><b>toUpperCase</b></code>()</code></font>
<p>
<a name="22805"></a>
If this <code>String</code> object does not contain any character that is mapped to a different 
character by the method <code>Character.toUpperCase</code> <a href="javalang.doc4.html#9154">(&#167;20.5.21)</a>, then a reference 
to this <code>String</code> object is returned. Otherwise, this method creates a new <code>String</code> 
object representing a character sequence identical in length to the character 
sequence represented by this <code>String</code> object and with every character equal to the 
result of applying the method <code>Character.toUpperCase</code> to the corresponding 
character of this <code>String</code> object.
<p><a name="25418"></a>
Examples:<p>
<pre><br><a name="25419"></a>"Fahrvergn&uuml;gen".toUpperCase() returns "FAHRVERGN&Uuml;GEN"
<br><a name="25420"></a>"Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
</pre><a name="14012"></a>
<p><font size=+1><strong>20.12.37   </strong> <code>public String <code><b>trim</b></code>()</code></font>
<p>
<a name="4737"></a>
If this <code>String</code> object represents an empty character sequence, or the first and last 
characters of character sequence represented by this <code>String</code> object both have 
codes greater than <code>\u0020</code> (the space character), then a reference to this <code>String</code> 
object is returned.
<p><a name="4745"></a>
Otherwise, if there is no character with a code greater than <code>\u0020</code> in the string, then a new <code>String</code> object representing an empty string is created and returned.<p>
<a name="4754"></a>
Otherwise, let <i>k</i> be the index of the first character in the string whose code is greater than <code>\u0020</code>, and let <i>m</i> be the index of the last character in the string whose code is greater than <code>\u0020</code>. A new <code>String</code> object is created, representing the substring of this string that begins with the character at index <i>k</i> and ends with the character at index <i>m</i>-that is, the result of <code>this.substring(</code><i>k</i><code>, </code><i>m</i><code>+1)</code>.<p>
<a name="4768"></a>
This method may be used to trim whitespace <a href="javalang.doc10.html#36320">(&#167;20.5.19)</a> from the beginning and end of a string; in fact, it trims all ASCII control characters as well.<p>
<a name="14015"></a>
<p><font size=+1><strong>20.12.38   </strong> <code>public static String <code><b>valueOf</b></code>(Object obj)</code></font>
<p>
<a name="4776"></a>
If the argument is <code>null</code>, then a string equal to <code>"null"</code> is returned. Otherwise, the 
value of <code>obj.toString()</code> is returned. See the <code>toString</code> method <a href="javalang.doc1.html#1152">(&#167;20.1.2)</a>.
<p><a name="4778"></a>
<p><font size=+1><strong>20.12.39   </strong> <code>public static String <code><b>valueOf</b></code>(char[] data)<br>throws NullPointerException</code></font>
<p>
<a name="4796"></a>
A string is created and returned. The string represents the sequence of characters 
currently contained in the character array argument. The contents of the character 
array are copied; subsequent modification of the character array does not affect 
the newly created string.
<p><a name="33348"></a>
<p><font size=+1><strong>20.12.40   </strong> <code>public static String <code><b>valueOf</b></code>(char[] data,<br> &#32; &#32; &#32;int offset, int count) <br>throws NullPointerException, <br> &#32; &#32; &#32;IndexOutOfBoundsException</code></font>
<p>
<a name="4805"></a>
A string is created and returned. The string represents the sequence of characters 
currently contained in a subarray of the character array argument. The <code>offset</code> 
argument is the index of the first character of the subarray and the <code>count</code> argument
specifies the length of the subarray. The contents of the subarray are copied; 
subsequent modification of the character array does not affect the newly created 
string.
<p><a name="25485"></a>
If <code>data</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="25493"></a>
If <code>offset</code> is negative, or <code>count</code> is negative, or <code>offset+count</code> is larger than <code>data.length</code>, then an <code>IndexOutOfBoundsException</code> is thrown.<p>
<a name="14020"></a>
<p><font size=+1><strong>20.12.41   </strong> <code>public static String <code><b>valueOf</b></code>(boolean b)</code></font>
<p>
<a name="21730"></a>
A string representation of <code>b</code> is returned.
<p><a name="4813"></a>
If the argument is <code>true</code>, the string <code>"true"</code> is returned.<p>
<a name="4814"></a>
If the argument is <code>false</code>, the string <code>"false"</code> is returned.<p>
<a name="14021"></a>
<p><font size=+1><strong>20.12.42   </strong> <code>public static String <code><b>valueOf</b></code>(char c)</code></font>
<p>
<a name="4790"></a>
A string is created and returned. The string contains one character, equal to <code>c</code>.
<p><a name="14022"></a>
<p><font size=+1><strong>20.12.43   </strong> <code>public static String <code><b>valueOf</b></code>(int i)</code></font>
<p>
<a name="4819"></a>
A string is created and returned. The string is computed exactly as if by the 
method <code>Integer.toString</code> of one argument <a href="javalang.doc6.html#1459">(&#167;20.7.12)</a>.
<p><a name="14023"></a>
<p><font size=+1><strong>20.12.44   </strong> <code>public static String <code><b>valueOf</b></code>(long l)</code></font>
<p>
<a name="4831"></a>
A string is created and returned. The string is computed exactly as if by the 
method <code>Long.toString</code> of one argument <a href="javalang.doc7.html#1452">(&#167;20.8.12)</a>.
<p><a name="14024"></a>
<p><font size=+1><strong>20.12.45   </strong> <code>public static String <code><b>valueOf</b></code>(float f)</code></font>
<p>
<a name="4838"></a>
A string is created and returned. The string is computed exactly as if by the 
method <code>Float.toString</code> of one argument <a href="javalang.doc8.html#1466">(&#167;20.9.16)</a>.
<p><a name="14025"></a>
<p><font size=+1><strong>20.12.46   </strong> <code>public static String <code><b>valueOf</b></code>(double d)</code></font>
<p>
<a name="4845"></a>
A string is created and returned. The string is computed exactly as if by the 
method <code>Double.toString</code> of one argument <a href="javalang.doc9.html#5899">(&#167;20.10.15)</a>.
<p><a name="14026"></a>
<p><font size=+1><strong>20.12.47   </strong> <code>public String <code><b>intern</b></code>()</code></font>
<p>
<a name="4858"></a>
A pool of strings, initially empty, is maintained privately by the class <code>String</code>.
<p><a name="4859"></a>
When the intern method is invoked, if the pool already contains a string equal to this <code>String</code> object as determined by the <code>equals</code> method <a href="javalang.doc14.html#29026">(&#167;20.12.9)</a>, then the string from the pool is returned. Otherwise, this <code>String</code> object is added to the pool and a reference to this <code>String</code> object is returned.<p>
<a name="4863"></a>
It follows that for any two strings <code>s</code> and <code>t</code>, <code>s.intern() == t.intern()</code> is <code>true</code> if and only if <code>s.equals(t)</code> is <code>true</code>.<p>
<a name="32459"></a>
All literal strings and string-valued constant expressions are interned <a href="3.doc.html#101083">(&#167;3.10.5)</a>.<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javalang.doc10.html">Prev</a> | <a href="javalang.doc12.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright &#169 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

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