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

📄 javalang.doc11.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<p><a name="4074"></a>
Overrides the <code>toString</code> method of <code>Object</code> <a href="javalang.doc1.html#1152">(&#167;20.1.2)</a>.<p>
<a name="2573"></a>
<p><font size=+1><strong>20.12.9   </strong> <code>public boolean <code><b>equals</b></code>(Object anObject)</code></font>
<p>
<a name="4078"></a>
The result is <code>true</code> if and only if the argument is not <code>null</code> and is a <code>String</code> object 
that represents the same sequence of characters as this <code>String</code> object.
<p><a name="4082"></a>
Overrides the <code>equals</code> method of <code>Object</code> <a href="javalang.doc1.html#14865">(&#167;20.1.3)</a>.<p>
<a name="4108"></a>
See also the methods <code>equalsIgnoreCase</code> <a href="javalang.doc11.html#13990">(&#167;20.12.16)</a> and <code>compareTo</code> <a href="javalang.doc11.html#13991">(&#167;20.12.17)</a>.<p>
<a name="2574"></a>
<p><font size=+1><strong>20.12.10   </strong> <code>public int <code><b>hashCode</b></code>()</code></font>
<p>
<a name="4181"></a>
The hashcode for a <code>String</code> object is computed in one of two ways, depending on 
its length. Let <i>n</i> be the length <a href="javalang.doc11.html#13985">(&#167;20.12.11)</a> of the character sequence and let <img src="javalang.doc.anc36.gif"> 
mean the character with index <i>i</i>.
<p><ul><a name="4202"></a>
<li>If <img src="javalang.doc.anc37.gif">, then the hashcode is computed as<img src="javalang.doc.anc21.gif"><br> using <code>int</code> arithmetic.
<a name="4212"></a>
<li>If <img src="javalang.doc.anc39.gif">, then the hashcode is computed as<img src="javalang.doc.anc38.gif"><br>using <code>int</code> arithmetic, where <img src="javalang.doc.anc40.gif"> and <img src="javalang.doc.anc41.gif">, sampling only eight or nine characters of the string.
</ul><a name="4099"></a>
Overrides the <code>hashCode</code> method of <code>Object</code> <a href="javalang.doc1.html#13784">(&#167;20.1.4)</a>.<p>
<a name="13985"></a>
<p><font size=+1><strong>20.12.11   </strong> <code>public int <code><b>length</b></code>()</code></font>
<p>
<a name="4123"></a>
The length of the sequence of characters represented by this <code>String</code> object is 
returned.
<p><a name="13986"></a>
<p><font size=+1><strong>20.12.12   </strong> <code>public char <code><b>charAt</b></code>(int index)<br>throws <code>IndexOutOfBoundsException</code></code></font>
<p>
<a name="4241"></a>
This method returns the character indicated by the <code>index</code> argument within the 
sequence of characters represented by this <code>String</code>. The first character of the 
sequence is at index <code>0</code>, the next at index <code>1</code>, and so on, as for array indexing. If the 
<code>index</code> argument is negative or not less than the length <a href="javalang.doc11.html#13985">(&#167;20.12.11)</a> of this string, 
then an <code>IndexOutOfBoundsException</code> is thrown.
<p><a name="4251"></a>
<p><font size=+1><strong>20.12.13   </strong> <code>public void <code><b>getChars</b></code>(int srcBegin, int srcEnd,<br>	 &#32; &#32; &#32;char dst[], int dstBegin)<br>throws NullPointerException,<br> &#32; &#32; &#32;IndexOutOfBoundsException</code></font>
<p>
<a name="4268"></a>
Characters are copied from this <code>String</code> object 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> (thus 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 <code>dstbegin+(srcEnd-srcBegin)-1</code>.
<p><a name="31249"></a>
If <code>dst</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="31263"></a>
An <code>IndexOutOfBoundsException</code> is thrown if any of the following is true:<p>
<ul><a name="31250"></a>
<li><code>srcBegin</code> is negative
<a name="31268"></a>
<li><code>srcBegin</code> is greater than <code>srcEnd</code>
<a name="31276"></a>
<li><code>srcEnd</code> is greater than the length of this String
<a name="31280"></a>
<li><code>dstBegin</code> is negative
<a name="31283"></a>
<li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than <code>dst.length</code>
</ul><a name="4252"></a>
<p><font size=+1><strong>20.12.14   </strong> <code>public void <code><b>getBytes</b></code>(int srcBegin, int srcEnd,<br> &#32; &#32; &#32;byte dst[], int dstBegin)<br>throws NullPointerException, <br> &#32; &#32; &#32;IndexOutOfBoundsException</code></font>
<p>
<a name="4273"></a>
Characters are copied from this <code>String</code> object into the destination byte array <code>dst</code>. 
Each byte receives only the eight low-order bits of the corresponding character. 
The eight high-order bits of each character are not copied and do not participate in 
the transfer in any way. 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> (thus the total number of characters
to be copied is <code>srcEnd-srcBegin</code>). The characters, converted to bytes, are 
copied into the subarray of <code>dst</code> starting at index <code>dstBegin</code> and ending at index 
<code>dstbegin+(srcEnd-srcBegin)-1</code>.
<p><a name="31285"></a>
If <code>dst</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="31286"></a>
An <code>IndexOutOfBoundsException</code> is thrown if any of the following is true:<p>
<ul><a name="31287"></a>
<li><code>srcBegin</code> is negative
<a name="31288"></a>
<li><code>srcBegin</code> is greater than <code>srcEnd</code>
<a name="31289"></a>
<li><code>srcEnd</code> is greater than the length of this <em>String</em>
<a name="31290"></a>
<li><code>dstBegin</code> is negative
<a name="31291"></a>
<li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than <code>dst.length</code>
</ul><a name="2612"></a>
<p><font size=+1><strong>20.12.15   </strong> <code>public char[] <code><b>toCharArray</b></code>()</code></font>
<p>
<a name="4279"></a>
A new character array is created and returned. The length of the array is equal to 
the length <a href="javalang.doc11.html#13985">(&#167;20.12.11)</a> of this <code>String</code> object. The array is initialized to contain the 
character sequence represented by this <code>String</code> object.
<p><a name="13990"></a>
<p><font size=+1><strong>20.12.16   </strong> <code>public boolean <code><b>equalsIgnoreCase</b></code>(String anotherString)</code></font>
<p>
<a name="4299"></a>
The result is <code>true</code> if and only if the argument is not <code>null</code> and is a <code>String</code> object 
that represents the same sequence of characters as this <code>String</code> object, where case 
is ignored.
<p><a name="4302"></a>
Two characters are considered the same, ignoring case, if at least one of the following is true:<p>
<ul><a name="4303"></a>
<li>The two characters are the same (as compared by the <code>==</code> operator).
<a name="4307"></a>
<li>Applying the method <code>Character.toUppercase</code> <a href="javalang.doc4.html#9154">(&#167;20.5.21)</a> to each character produces the same result.
<a name="4311"></a>
<li>Applying the method <code>Character.toLowercase</code> <a href="javalang.doc4.html#20313">(&#167;20.5.20)</a> to each character produces the same result.
</ul><a name="4357"></a>
Two sequences of characters are the same, ignoring case, if the sequences have the same length and corresponding characters are the same, ignoring case.<p>
<a name="4117"></a>
See also the method <code>equals</code> <a href="javalang.doc14.html#29026">(&#167;20.12.9)</a>.<p>
<a name="13991"></a>
<p><font size=+1><strong>20.12.17   </strong> <code>public int <code><b>compareTo</b></code>(String anotherString)<br>throws NullPointerException</code></font>
<p>
<a name="4362"></a>
The character sequence represented by this <code>String</code> object is compared lexicographically
to the character sequence represented by the argument string. The 
result is a negative integer if this <code>String</code> object lexicographically precedes the 
argument string. The result is a positive integer if this <code>String</code> object lexicographically
follows the argument string. The result is zero if the strings are equal; <code>compareTo
</code> returns <code>0</code> exactly when the <code>equals</code> method <a href="javalang.doc14.html#29026">(&#167;20.12.9)</a> would return <code>true</code>.
<p><a name="31297"></a>
If <code>anotherString</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="4387"></a>
This is the definition of lexicographic ordering. If two strings are different, then either they have different characters at some index that is a valid index for both strings, or their lengths are different, or both. If they have different characters at one or more index positions, let <i>k</i> be the smallest such index; then the string whose character at position <i>k</i> has the smaller value, as determined by using the <code>&lt;</code> operator, lexicographically precedes the other string. In this case, <code>compareTo</code> returns the difference of the two character values at position <i>k</i> in the two strings- that is, the value:<p>
<pre><a name="4394"></a>this.charAt(<i>k</i>)-anotherString.charAt(<i>k</i>)
</pre><a name="4395"></a>
If there is no index position at which they differ, then the shorter string lexicographically
precedes the longer string. In this case, <code>compareTo</code> returns the difference
of the lengths of the strings-that is, the value:
<p><pre><a name="25174"></a>this.length()-anotherString.length()
</pre><a name="4360"></a>
<p><font size=+1><strong>20.12.18   </strong> <code>public boolean <code><b>regionMatches</b></code>(int toffset,<br> &#32; &#32; &#32;String other, int ooffset, int len)<br>throws NullPointerException</code></font>
<p>
<a name="4866"></a>
A substring of this <code>String</code> object is compared to a substring of the argument 
<code>other</code>. The result is <code>true</code> if these substrings represent identical character 
sequences. The substring of this <code>String</code> object to be compared begins at index 
<code>toffset</code> and has length <code>len</code>. The substring of <code>other</code> to be compared begins at 
index <code>ooffset</code> and has length <code>len</code>. The result is <code>false</code> if and only if at least one 
of the following is true:
<p><ul><a name="4882"></a>
<li><code>toffset</code> is negative.
<a name="4876"></a>
<li><code>ooffset</code> is negative.
<a name="4883"></a>
<li><code>toffset+len</code> is greater than the length of this <code>String</code> object.
<a name="4884"></a>
<li><code>ooffset+len</code> is greater than the length of the <code>other</code> argument.
<a name="4885"></a>
<li>There is some nonnegative integer <i>k</i> less than <code>len</code> such that:
<a name="4886"></a>this.charAt(toffset+<i>k</i>) != other.charAt(ooffset+<i>k</i>)
</ul><a name="31301"></a>
If <code>other</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.
<p><a name="13993"></a>
<p><font size=+1><strong>20.12.19   </strong> <code>public boolean <code><b>regionMatches</b></code>(boolean ignoreCase,<br> &#32; &#32; &#32;int toffset, String other, int ooffset, int len)<br>throws NullPointerException</code></font>
<p>
<a name="4893"></a>
A substring of this <code>String</code> object is compared to a substring of the argument 
<code>other</code>. The result is <code>true</code> if these substrings represent character sequences that 
are the same, ignoring case if and only if <code>ignoreCase</code> is true. The substring of 
this <code>String</code> object to be compared begins at index <code>toffset</code> and has length <code>len</code>. 
The substring of <code>other</code> to be compared begins at index <code>ooffset</code> and has length 
<code>len</code>. The result is <code>false</code> if and only if at least one of the following is true:
<p><ul><a name="4894"></a>
<li><code>toffset</code> is negative.
<a name="4895"></a>
<li><code>ooffset</code> is negative.

⌨️ 快捷键说明

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