Java Reference
In-Depth Information
public String substring( int start, int end)
Returns the substring of the calling object string 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 character at position start is included in the value returned, but the character at
position end is not included.
EXAMPLE
After program executes String sample = "AbcdefG";
sample.substring(2, 5) returns "cde" .
Throws:
IndexOutOfBoundsException if the start is negative, or end is larger than the length of
this String object, or start is larger than end.
public String toLowerCase()
Returns a string with the same characters as the calling object string, but with all letter charac-
ters converted to lowercase.
EXAMPLE
After program executes String greeting = "Hi Mary!";
greeting.toLowerCase() returns "hi mary!" .
public String toUpperCase()
Returns a string with the same characters as the calling object string, but with all letter charac-
ters converted to uppercase.
EXAMPLE
After program executes String greeting = "Hi Mary!";
greeting.toUpperCase() returns "HI MARY!" .
public String trim()
Returns a string with the same characters as the calling object string, but with leading and trail-
ing whitespace removed. Whitespace characters are the characters that print as whitespace on
paper, such as the blank (space) character, the tab character, and the new-line character '\n'.
EXAMPLE
After program executes String pause = " Hmm ";
pause.trim() returns "Hmm".
StringBuffer
Package: java.lang
StringBuffer is marked final and so you cannot use it as a base class to derive
another class.
Ancestor classes:
Object
|
+--StringBuffer
 
Search WWH ::




Custom Search