HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The Java Math class has many methods that allows you to perform mathematical tasks on numbers
The Math.max(x,y)
method can be used to find the highest value of x and
y:
The Math.min(x,y)
method can be used to find the lowest value of x
and y:
The Math.sqrt(x)
method returns the square root of x:
The Math.abs(x)
method returns the absolute (positive) value of x:
Math.random()
returns a random number between 0.0 (inclusive), and 1.0 (exclusive):
To get more control over the random number, e.g. you only want a random number between 0 and 100, you can use the following formula:
For a complete reference of Math methods, go to our Java Math Methods Reference.