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 |
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 |
Math.sqrt(x)
method returns the square root of x
:
System.out.println( Math.sqrt( 36.0 ) ); // Output: 6.0 |