Java Reference

In-Depth Information

C H A P T E R 4

Touring Language APIs

Java's standard class library provides various language-oriented APIs. Most of these

APIs reside in the
java.lang
package and its subpackages, although a few APIs

Math
and
StrictMath
,
Package
, Primitive Type Wrapper Class, Reference, Re-

flection,
String
,
StringBuffer
and
StringBuilder
,
System
, and Threading

APIs. This chapter then introduces you to
java.math
's
BigDecimal
and
BigIn-

teger
APIs.

Math and StrictMath

The
java.lang.Math
class declares
double
constants
E
and
PI
that represent the

natural logarithm base value (2.71828...) and the ratio of a circle's circumference to its

diameter(3.14159...).
E
isinitializedto
2.718281828459045
and
PI
isinitializedto

3.141592653589793
.
Math
alsodeclaresassortedclassmethodstoperformvarious

math operations.
Table 4-1
describes many of these methods.