Java Reference
In-Depth Information
•
String
method
replace
returns a new string object that replaces every occurrence in a
String
of
its first character argument with its second character argument.
•
String
method
toUpperCase
(p. 609) returns a new string with uppercase letters in the positions
where the original string had lowercase letters.
String
method
toLowerCase
(p. 610) returns a
new string with lowercase letters in the positions where the original string had uppercase letters.
•
String
method
trim
(p. 610) returns a new string object in which all white-space characters (e.g.,
spaces, newlines and tabs) have been removed from the beginning and end of a string.
•
String
method
toCharArray
(p. 610) returns a
char
array containing a copy of the string's char-
acters.
•
String
class
static
method
valueOf
returns its argument converted to a string.
Section 14.4 Class
StringBuilder
• Class
StringBuilder
provides constructors that enable
StringBuilder
s to be initialized with no
characters and an initial capacity of 16 characters, with no characters and an initial capacity spec-
ified in the integer argument, or with a copy of the characters of the
String
argument and an
initial capacity that's the number of characters in the
String
argument plus 16.
•
StringBuilder
method
length
(p. 612) returns the number of characters currently stored in a
StringBuilder
.
StringBuilder
method
capacity
(p. 612)
returns the number of characters that
can be stored in a
StringBuilder
without allocating more memory.
•
StringBuilder
method
ensureCapacity
(p. 613) ensures that a
StringBuilder
has at least the
specified capacity.
M
ethod
setLength
increases or decreases the length of a
StringBuilder
.
•
StringBuilder
method
charAt
(p. 614) returns the character at the specified index. Method
setCharAt
(p. 614) sets the character at the specified position.
StringBuilder
method
getChars
(p. 614)
copies characters in the
StringBuilder
into the character array passed as an argument.
•
StringBuilder
's overloaded
append
methods (p. 615) add primitive-type, character-array,
String
,
Object
or
CharSequence
(p. 615)
values to the end of a
StringBuilder
.
•
StringBuilder
's overloaded
insert
(p. 617) methods insert primitive-type, character-array,
String
,
Object
or
CharSequence
values at any position in a
StringBuilder
.
Section 14.5 Class
Character
•
Character
method
isDefined
(p. 620) determines whether a character is in the Unicode charac-
ter set.
•
Character
method
isDigit
(p. 620) determines whether a character is a defined Unicode digit.
•
Character
method
isJavaIdentifierStart
(p. 620) determines whether a character can be used
as the first character of a Java identifier.
Character
method
isJavaIdentifierPart
(p. 620)
de-
termines if a character can be used in an identifier.
•
Character
method
isLetter
(p. 620) determines whether a character is a letter.
Character
meth-
od
isLetterOrDigit
(p. 620) determines if a character is a letter or a digit.
•
Character
method
isLowerCase
(p. 620) determines whether a character is a lowercase letter.
Character
method
isUpperCase
(p. 620) determines whether a character is an uppercase letter.
•
Character
method
toUpperCase
(p. 620) converts a character to its uppercase equivalent.
Char-
acter
method
toLowerCase
(p. 621) converts a character to its lowercase equivalent.
•
Character
method
digit
(p. 621) converts its character argument into an integer in the number
system specified by its integer argument
radix
(p. 621).
Character
method
forDigit
(p. 621)
converts its integer argument
digit
into a character in the number system specified by its integer
argument
radix
.