1904 if (subLen < 0) {
1905 throw new StringIndexOutOfBoundsException(subLen);
1906 }
1907 return ((beginIndex == 0) && (endIndex == value.length)) ? this
1908 : new String(value, beginIndex, subLen);
1909 }
1910
1911 /**
1912 * Returns a new character sequence that is a subsequence of this sequence.
1913 *
1914 * <p> An invocation of this method of the form
1915 *
1916 * <blockquote><pre>
1917 * str.subSequence(begin, end)</pre></blockquote>
1918 *
1919 * behaves in exactly the same way as the invocation
1920 *
1921 * <blockquote><pre>
1922 * str.substring(begin, end)</pre></blockquote>
1923 *
1924 * This method is defined so that the <tt>String</tt> class can implement
1925 * the {@link CharSequence} interface. </p>
1926 *
1927 * @param beginIndex the begin index, inclusive.
1928 * @param endIndex the end index, exclusive.
1929 * @return the specified subsequence.
1930 *
1931 * @throws IndexOutOfBoundsException
1932 * if <tt>beginIndex</tt> or <tt>endIndex</tt> are negative,
1933 * if <tt>endIndex</tt> is greater than <tt>length()</tt>,
1934 * or if <tt>beginIndex</tt> is greater than <tt>startIndex</tt>
1935 *
1936 * @since 1.4
1937 * @spec JSR-51
1938 */
1939 public CharSequence subSequence(int beginIndex, int endIndex) {
1940 return this.substring(beginIndex, endIndex);
1941 }
1942
1943 /**
1944 * Concatenates the specified string to the end of this string.
1945 * <p>
1946 * If the length of the argument string is {@code 0}, then this
1947 * {@code String} object is returned. Otherwise, a new
1948 * {@code String} object is created, representing a character
1949 * sequence that is the concatenation of the character sequence
1950 * represented by this {@code String} object and the character
1951 * sequence represented by the argument string.<p>
1952 * Examples:
1953 * <blockquote><pre>
1954 * "cares".concat("s") returns "caress"
|
1904 if (subLen < 0) {
1905 throw new StringIndexOutOfBoundsException(subLen);
1906 }
1907 return ((beginIndex == 0) && (endIndex == value.length)) ? this
1908 : new String(value, beginIndex, subLen);
1909 }
1910
1911 /**
1912 * Returns a new character sequence that is a subsequence of this sequence.
1913 *
1914 * <p> An invocation of this method of the form
1915 *
1916 * <blockquote><pre>
1917 * str.subSequence(begin, end)</pre></blockquote>
1918 *
1919 * behaves in exactly the same way as the invocation
1920 *
1921 * <blockquote><pre>
1922 * str.substring(begin, end)</pre></blockquote>
1923 *
1924 * This method is defined so that the {@code String} class can implement
1925 * the {@link CharSequence} interface. </p>
1926 *
1927 * @param beginIndex the begin index, inclusive.
1928 * @param endIndex the end index, exclusive.
1929 * @return the specified subsequence.
1930 *
1931 * @throws IndexOutOfBoundsException
1932 * if {@code beginIndex} or {@code endIndex} is negative,
1933 * if {@code endIndex} is greater than {@code length()},
1934 * or if {@code beginIndex} is greater than {@code endIndex}
1935 *
1936 * @since 1.4
1937 * @spec JSR-51
1938 */
1939 public CharSequence subSequence(int beginIndex, int endIndex) {
1940 return this.substring(beginIndex, endIndex);
1941 }
1942
1943 /**
1944 * Concatenates the specified string to the end of this string.
1945 * <p>
1946 * If the length of the argument string is {@code 0}, then this
1947 * {@code String} object is returned. Otherwise, a new
1948 * {@code String} object is created, representing a character
1949 * sequence that is the concatenation of the character sequence
1950 * represented by this {@code String} object and the character
1951 * sequence represented by the argument string.<p>
1952 * Examples:
1953 * <blockquote><pre>
1954 * "cares".concat("s") returns "caress"
|