How to get the minimum or maximum value between two numbers?
The code below show you how to use the
Math.max() method call the get the minimum and maximum value between two numbers. As other method in the
Math class these methods also overloaded to accept many types of primitive data.
The result of the above program are:
Max value in double: 200.0
Min value in double: 100.0
Max value in float : 200.0
Min value in float : 100.0
Max value in int : 200
Min value in int : 100
Max value in long : 200
Min value in long : 100