Java Reference
In-Depth Information
TABLE 7-1
Some Predefined Mathematical Methods and Named Constants (continued)
class
Math
(Package:
java.lang
)
x
is of type
double
. Returns a value of type
double
, which is the
square root of
x
.
Example:
sqrt(4.0)
returns the value
2.0
sqrt(2.25)
returns the value
1.5
sqrt(x)
x
is of type
double
. Returns the cosine of
x
measured in radians.
Example:
cos(0)
returns the value
1.0
cos(PI / 3)
returns the value
0.5000000000000001
cos(x)
x
is of type
double
. Returns the sine of
x
measured in radians.
Example:
sin(0)
returns the value
0.0
sin(PI / 2)
returns the value
1.0
sin(x)
x
is of type
double
. Returns the tangent of
x
measured in radians.
Example:
tan(0)
returns the value
0.0
tan(x)
7
The method
log10
is not available in Java versions lower than 5.0.
Java also provides methods, contained in the
class
Character
, to manipulate characters.
Table 7-2 describes some of the methods of the
class
Character
contained in the
package
java.lang
. As in Table 7-1, Table 7-2 shows the name of the method in bold
and gives examples of how the methods work.
TABLE 7-2
Some Predefined Methods for Character Manipulation
class
Character
(Package:
java.lang
)
Expression
Description
ch
is of type
char
. Returns
true
,if
ch
is a digit;
false
otherwise.
Example:
isDigit('8')
returns the value
true
isDigit('*')
returns the value
false
isDigit(ch)
ch
is of type
char
. Returns
true
,if
ch
is a letter;
false
otherwise.
Example:
isLetter('a')
returns the value
true
isLetter('*')
returns the value
false
isLetter(ch)
Search WWH ::
Custom Search