Java Reference
In-Depth Information
Because
pow( )
and
sqrt( )
are static methods, they must be called through the use of
their class' name,
Math
. This results in a somewhat unwieldy expression:
Furthermore, having to specify the class name each time
pow( )
or
sqrt( )
(or any of Java's
other math methods, such as
sin( )
,
cos( )
, and
tan( )
) are used can become tedious.
You can eliminate the tedium of specifying the class name through the use of static im-
port, as shown in the following version of the preceding program: