Java Reference
In-Depth Information
The output from the program is shown here:
Operating on Strings
The String class contains several methods that operate on strings. Here are the general
forms for a few:
boolean
equals( str )
Returns true if the invoking string contains the same character sequence
as str .
int length( )
Obtains the length of a string.
char charAt( in-
dex )
Obtains the character at the index specified by index .
Returns less than zero if the invoking string is less than str , greater than
zero if the invoking string is greater than str , and zero if the strings are
equal.
int indexOf( str ) Searches the invoking string for the substring specified by str . Returns
int com-
pareTo( str )
the index of the first match or -1 on failure.
Search WWH ::




Custom Search