Java Reference
In-Depth Information
public void setLength( int newLength)
Sets the length of the calling object. The calling object is altered to represent a new character
sequence whose length is specifi ed by the argument. For every nonnegative index k less than
newLength, the character at index k in the new character sequence is the same as the charac-
ter at index k in the old sequence. If the newLength argument is less than the current length of
the string buffer, the string buffer is truncated to contain exactly the number of characters given
by the newLength argument.
If the newLength argument is greater than the current length, suffi cient null characters ('\u0000')
are appended to the string buffer so that length becomes the newLength argument.
Throws:
IndexOutOfBoundsException if newLength is negative.
public String substring( int start)
Returns the substring of the calling object starting from start through to the end of the calling
object. Positions are counted 0, 1, 2, etc. Be sure to notice that the character at position start
is included in the value returned. Note that the substring is returned as a value of type String ,
not StringBuffer .
Throws:
StringIndexOutOfBoundsException if start is negative or larger than the length of the
calling object. StringIndexOutOfBoundsException is a derived class of RuntimeException ,
and so is an unchecked exception, which means it is not required to be caught or declared in a
throws clause.
public String substring( int start, int end)
Returns the substring of the calling object starting from position start through, but not including,
position end of the calling object. Positions are counted 0, 1, 2, etc. Be sure to notice that the char-
acter at position start is included in the value returned, but the character at position end is not
included. Also note that the substring is returned as a value of type String , not StringBuffer .
Throws:
StringIndexOutOfBoundsException if start is negative, or end is larger than the length
of this calling object, or start is larger than end . StringIndexOutOfBoundsException is a
derived class of RuntimeException , and so is an unchecked exception, which means it is not
required to be caught or declared in a throws clause.
public String toString()
Creates a new String object that contains the same character sequence calling object and
returns that String object. Subsequent changes to the calling object do not affect the contents
of the String returned.
StringTokenizer
Package: java.util .
Ancestor classes:
Object
|
+--StringTokenizer
 
Search WWH ::




Custom Search