Math Methods

The Java Math class provides several methods that allows us to work on mathematical calculations with numbers.

Math.method();

Here are the Math methods in alphabetical order:

Math Methods

.abs()
Returns the absolute value of the argument.
.acos()
Returns the inverse cosine of the argument in radians.
.asin()
Returns the inverse sine of the argument in radians.
.atan()
Returns the inverse tangent of the argument in radians.
.atan2()
Returns the counterclockwise angle, in radians, between a (x,y) point and the positive x-axis.
.pow()
Returns the first argument raised to the power of the second argument.
.random()
Returns a pseudorandom double that is 0.0 or greater, and less than 1.0.
.rint()
Returns a double that is rounded to the closest whole integer.
.sqrt()
Returns the positive, properly rounded square root of a double-type value.

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Java on Codecademy