The Java standard library places a large number of useful classes in the `java.lang` package. The Java compiler automatically imports this package for all programs, so no `import` statement is required. Because a working knowledge of these classes is essential for any Java programmer, you have probably used many of them already, so the purpose of this section is to review their most important aspects.

The `Math` class provides the usual mathematical functions and defines the commonly used constants, e and pi, as the `static double` variables `Math.E` and `Math.PI`. All elements of the `Math` class are `static`, so you never create an instance of `Math`. The `Math` class is itself `final` and so cannot be subclassed. ...

Start Free Trial

No credit card required