Math Class
The Java Math class has many methods that allow 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:
System.out.println( Math.max( 10, 20 ) ); // Output: 20
|
The
Math.min(x,y) method can be used to find the lowest value of
x and
y:
System.out.println( Math.min( 10.2, 20.5 ) ); // Output: 10.2
|
The
Math.sqrt(x) method returns the square root of
x:
System.out.println( Math.sqrt( 38.0 ) ); // Output: 8.0
|
“God will not look you over for medals, degrees or diplomas but for scars.”
― Elbert Hubbard
|