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

📄 javalang.doc11.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<a name="4896"></a>
<li><code>toffset+len</code> is greater than the length of this <code>String</code> object.
<a name="4897"></a>
<li><code>ooffset+len</code> is greater than the length of the <code>other</code> argument.
<a name="4909"></a>
<li>There is some nonnegative integer <i>k</i> less than <code>len</code> such that:
<a name="4910"></a>this.charAt(toffset+<i>k</i>) != other.charAt(ooffset+<i>k</i>)
<a name="4923"></a>
<li><code>ignoreCase</code> is <code>true</code> and there is some nonnegative integer <i>k</i> less than <code>len</code> such that:
</ul><pre><a name="4924"></a>
Character.toLowerCase(this.charAt(toffset+<i>k</i>)) !=
<a name="31309"></a>	Character.toLowerCase(other.charAt(ooffset+<i>k</i>))
</pre><ul><a name="4928"></a>
<br><br><code>and</code>:
</ul><pre><a name="4929"></a>
Character.toUpperCase(this.charAt(toffset+<i>k</i>)) !=
<a name="31308"></a>	Character.toUpperCase(other.charAt(ooffset+<i>k</i>))
</pre><a name="31305"></a>
If <code>other</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.
<p><a name="2586"></a>
<p><font size=+1><strong>20.12.20   </strong> <code>public boolean <code><b>startsWith</b></code>(String prefix)<br>throws NullPointerException</code></font>
<p>
<a name="4405"></a>
The result is <code>true</code> if and only if the character sequence represented by the argument
is a prefix of the character sequence represented by this <code>String</code> object.
<p><a name="4449"></a>
If <code>prefix</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.<p>
<a name="4416"></a>
Note that the result will be <code>true</code> if the argument is an empty string or is 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>.<p>
<a name="13994"></a>
<p><font size=+1><strong>20.12.21   </strong> <code>public boolean <code><b>startsWith</b></code>(String prefix, int toffset)<br>throws NullPointerException</code></font>
<p>
<a name="4418"></a>
The result is <code>true</code> if and only if the character sequence represented by the argument
is a prefix of the substring of this <code>String</code> object starting at index <code>toffset</code>.
<p><a name="4443"></a>
If <code>prefix</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="4430"></a>
The result is <code>false</code> if <code>toffset</code> is negative or greater than the length of this <code>String</code> object; otherwise, the result is the same as the result of the expression<p>
<pre><a name="4429"></a>this.subString(toffset).startsWith(prefix)
</pre><a name="13996"></a>
<p><font size=+1><strong>20.12.22   </strong> <code>public boolean <code><b>endsWith</b></code>(String suffix)<br>throws NullPointerException</code></font>
<p>
<a name="4629"></a>
The result is <code>true</code> if and only if the character sequence represented by the argument
is a suffix of the character sequence represented by this <code>String</code> object.
<p><a name="4630"></a>
If <code>suffix</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.<p>
<a name="4631"></a>
Note that the result will be <code>true</code> if the argument is an empty string or is 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>.<p>
<a name="13998"></a>
<p><font size=+1><strong>20.12.23   </strong> <code>public int <code><b>indexOf</b></code>(int ch)</code></font>
<p>
<a name="4452"></a>
If a character with value <code>ch</code> occurs in the character sequence represented by this 
<code>String</code> object, then the index of the first such occurrence is returned-that is, the 
smallest value <i>k</i> such that:
<p><pre><a name="4478"></a><code>this.charAt(</code><i>k</i><code>) == ch
</code></pre><a name="4479"></a>
is <code>true</code>. If no such character occurs in this string, then <code>-1</code> is returned.<p>
<a name="13999"></a>
<p><font size=+1><strong>20.12.24   </strong> <code>public int <code><b>indexOf</b></code>(int ch, int fromIndex)</code></font>
<p>
<a name="4460"></a>
If a character with value <code>ch</code> occurs in the character sequence represented by this 
<code>String</code> object at an index no smaller than <code>fromIndex</code>, then the index of the first 
such occurrence is returned-that is, the smallest value <i>k</i> such that:
<p><pre><a name="4480"></a><code>(this.charAt(</code><i>k</i><code>) == ch) &amp;&amp; (</code><i>k</i><code> &gt;= fromIndex)
</code></pre><a name="4481"></a>
is <code>true</code>. If no such character occurs in this string at or after position <code>fromIndex</code>, then <code>-1</code> is returned.<p>
<a name="4526"></a>
There is no restriction on the value of <code>fromIndex</code>. If it is negative, it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this string: <code>-1</code> is returned.<p>
<a name="4459"></a>
<p><font size=+1><strong>20.12.25   </strong> <code>public int <code><b>indexOf</b></code>(String str)<br>throws NullPointerException</code></font>
<p>
<a name="4483"></a>
If the string <code>str</code> occurs as a substring of this <code>String</code> object, then the index of the 
first character of the first such substring is returned-that is, the smallest value <i>k</i> 
such that:
<p><pre><a name="30900"></a><code>this.startsWith(str, </code><i>k</i><code>)
</code></pre><a name="30901"></a>
is <code>true</code>. If <code>str</code> does not occur as a substring of this string, then <code>-1</code> is returned.<p>
<a name="31313"></a>
If <code>str</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.<p>
<a name="30903"></a>
<p><font size=+1><strong>20.12.26   </strong> <code>public int <code><b>indexOf</b></code>(String str, int fromIndex)<br>throws NullPointerException</code></font>
<p>
<a name="4494"></a>
If the string <code>str</code> occurs as a substring of this <code>String</code> object starting at an index no 
smaller than <code>fromIndex</code>, then the index of the first character of the first such substring
is returned-that is, the smallest value <i>k</i> such that:
<p><pre><a name="4495"></a><code>this.startsWith(str, </code><i>k</i><code>) &amp;&amp; (</code><i>k</i><code> &gt;= fromIndex)
</code></pre><a name="4496"></a>
is <code>true</code>. If <code>str</code> does not occur as a substring of this string at or after position <code>fromIndex</code>, &#32;then <code>-1</code> is returned.<p>
<a name="4528"></a>
There is no restriction on the value of <code>fromIndex</code>. If it is negative, it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this string: <code>-1</code> is returned.<p>
<a name="31321"></a>
If <code>str</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.<p>
<a name="14000"></a>
<p><font size=+1><strong>20.12.27   </strong> <code>public int <code><b>lastIndexOf</b></code>(int ch)</code></font>
<p>
<a name="4539"></a>
If a character with value <code>ch</code> occurs in the character sequence represented by this 
<code>String</code> object, then the index of the last such occurrence is returned-that is, the 
largest value <i>k</i> such that:
<p><pre><a name="4540"></a><code>this.charAt(</code><i>k</i><code>) == ch
</code></pre><a name="4541"></a>
is true. If no such character occurs in this string, then <code>-1</code> is returned.<p>
<a name="14001"></a>
<p><font size=+1><strong>20.12.28   </strong> <code>public int <code><b>lastIndexOf</b></code>(int ch, int fromIndex)</code></font>
<p>
<a name="4553"></a>
If a character with value <code>ch</code> occurs in the character sequence represented by this 
<code>String</code> object at an index no larger than <code>fromIndex</code>, then the index of the last 
such occurrence is returned-that is, the largest value <i>k</i> such that:
<p><pre><a name="4554"></a><code>(this.charAt(</code><i>k</i><code>) == ch) &amp;&amp; (</code><i>k</i><code> &lt;= fromIndex)
</code></pre><a name="4555"></a>
is true. If no such character occurs in this string at or before position <code>fromIndex</code>, then <code>-1</code> is returned.<p>
<a name="4556"></a>
There is no restriction on the value of <code>fromIndex</code>. If it is greater than or equal to the length of this string, it has the same effect as if it were equal to one less than the length of this string: this entire string may be searched. If it is negative, it has the same effect as if it were <code>-1</code>: <code>-1</code> is returned.<p>
<a name="14004"></a>
<p><font size=+1><strong>20.12.29   </strong> <code>public int <code><b>lastIndexOf</b></code>(String str)<br>throws NullPointerException</code></font>
<p>
<a name="4586"></a>
If the string <code>str</code> occurs as a substring of this <code>String</code> object, then the index of the 
first character of the last such substring is returned-that is, the largest value <i>k</i> 
such that:
<p><pre><a name="4587"></a><code>this.startsWith(str, </code><i>k</i><code>)
</code></pre><a name="4588"></a>
is true. If <code>str</code> does not occur as a substring of this string, then <code>-1</code> is returned.<p>
<a name="31323"></a>
If <code>str</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.<p>
<a name="4608"></a>
<p><font size=+1><strong>20.12.30   </strong> <code>public int <code><b>lastIndexOf</b></code>(String str, int fromIndex)<br>throws NullPointerException</code></font>
<p>
<a name="4609"></a>
If the string <code>str</code> occurs as a substring of this <code>String</code> object starting at an index no 
larger than <code>fromIndex</code>, then the index of the first character of the last such substring
is returned-that is, the largest value <i>k</i> such that:
<p><pre><a name="4599"></a><code>this.startsWith(str, </code><i>k</i><code>) &amp;&amp; (</code><i>k</i><code> &lt;= fromIndex)
</code></pre><a name="4600"></a>
is <code>true</code>. If <code>str</code> does not occur as a substring of this string at or before position <code>fromIndex</code>, then <code>-1</code> is returned.<p>
<a name="4625"></a>
There is no restriction on the value of <code>fromIndex</code>. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this string: this entire string may be searched. If it is negative, it has the same effect as if it were <code>-1</code>: <code>-1</code> is returned.<p>
<a name="31325"></a>
If <code>str</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.<p>
<a name="4668"></a>
<p><font size=+1><strong>20.12.31   </strong> <code>public String <code><b>substring</b></code>(int beginIndex)<br>throws <code>IndexOutOfBoundsException</code></code></font>
<p>
<a name="4669"></a>
The result is a newly created <code>String</code> object that represents a subsequence of the 
character sequence represented by this <code>String</code> object; this subsequence begins 
with the character at position <code>beginIndex</code> and extends to the end of the character 
sequence.
<p><a name="4660"></a>
If <code>beginIndex</code> is negative or larger than the length of this <code>String</code> object, then an <code>IndexOutOfBoundsException</code> is thrown.<p>
<a name="25364"></a>
Examples:<p>
<pre><br><a name="25365"></a>"unhappy".substring(2) returns "happy"
<br><br><a name="25374"></a>"Harbison".substring(3) returns "bison"
<br><a name="30913"></a>"emptiness".substring(9) returns "" (an empty string)
</pre><a name="14007"></a>
<p><font size=+1><strong>20.12.32   </strong> <code>public String <code><b>substring</b></code>(int beginIndex, int endIndex)<br>throws <code>IndexOutOfBoundsException</code></code></font>
<p>
<a name="4652"></a>
The result is a newly created <code>String</code> object that represents a subsequence of the 
character sequence represented by this <code>String</code> object; this subsequence begins 
with the character at position <code>beginIndex</code> and ends with the character at position 
<code>endIndex-1</code>. Thus, the length of the subsequence is <code>endIndex-beginIndex</code>.
<p><a name="4686"></a>
If <code>beginIndex</code> is negative, or <code>endIndex</code> is larger than the length of this <code>String</code> object, or <code>beginIndex</code> is larger than <code>endIndex</code>, then this method throws an <code>IndexOutOfBoundsException</code>.<p>
<a name="25371"></a>

⌨️ 快捷键说明

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