Utility Classes in the java.lang Package

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

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. ...

Get Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.