Java Reference
In-Depth Information
TABLE 7-2 Some Predefined Methods for Character Manipulation (continued)
class Character (Package: java.lang )
Expression
Description
ch is of type char . Returns true ,if ch is a lowercase
letter; false otherwise.
Example:
isLowerCase('a') returns the value true
isLowerCase('A') returns the value false
isLowerCase(ch)
ch is of type char . Returns true ,if ch is an uppercase
letter; false otherwise.
Example:
isUpperCase('B') returns the value true
isUpperCase('k') returns the value false
isUpperCase(ch)
ch is of type char . Returns the character that is the
lowercase equivalent of ch .If ch does not have the
corresponding lowercase letter, it returns ch .
Example:
toLowerCase('D') returns the value d
toLowerCase('*') returns the value *
toLowerCase(ch)
ch is of type char . Returns the character that is the
uppercase equivalent of ch .If ch does not have the
corresponding uppercase letter, it returns ch .
Example:
toUpperCase('j') returns the value J
toUpperCase('8') returns the value 8
toUpperCase(ch)
Using Predefined Methods in a Program
In general, to use the predefined methods of a class in a program, you must import the
class from the package containing the class. For example, to use the method nextInt
of the class Scanner contained in the package java.util , we imported this class
from the package java.util . However, as stated in Chapter 2, if a class is contained
in the package java.lang and you want to use a ( public ) method of this class , Java
does not require you to include an explicit import statement to import that class . For
example, to use any ( public ) method of the class String contained in the package
java.lang in a program, we do not need an import statement. By default, Java
automatically imports classes from the package java.lang .
A method of a class may contain the reserved word static (in its heading). For example,
the method main contains the reserved word static in its heading. If (the heading of ) a
method contains the reserved word static , it is called a static method; otherwise, it is
 
Search WWH ::




Custom Search