O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.4. The Math Class

The final class Math defines a set of static methods to support common mathematical functions, including functions for rounding numbers, performing trigonometry, generating pseudo random numbers, finding maximum and minimum of two numbers, calculating logarithms and exponentiation. The Math class cannot be instantiated. Only the class name Math can be used to invoke the static methods.

The final class Math provides constants to represent the value of e, the base of the natural logarithms, and the value π (pi), the ratio of the circumference of a circle to its diameter:

Math.E
Math.PI

Miscellaneous Rounding Functions

static int    abs(int i)
static long   abs(long l)
static float  abs(float f)
static double abs(double d)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required