Java Math
The Java Math class has many methods that allows you to perform mathematical tasks on numbers.
Math.max(x,y)
The Mathmax(x,y)
. method can be used to find the highest value of x and y:
Example
Math.max(5, 10);
Math.min(x,y)
The Math.min(x,y)
method can be used to find the lowest value of x and y:
Example
Math.min(5, 10);
Math.abs(x)
The Math.abs(x)()
The method returns the absolute (positive) value of x:
Example
Math.abs
Random Numbers
The Math.random()
returns a random number between 0.0 (inclusive), and 1.0 (exclusive):
Example
Math.random