Skip to content

Find Maximum number using max method of Math class in Java

Java Math max method example shows how to find the maximum of two numbers using the max method of Java Math class.

How to find a maximum of two numbers using Math class?

We can use the max static method of the Java Math class to find the a maximum of two numbers.

This method returns the maximum of two integer numbers.

The max method has been overloaded for double, float, and long data types so that the same method can be used for double, float, and long types.

Output

How to find the maximum number of 3 or more numbers?

The max method of Math class accepts only two arguments. So directly, a maximum of 3 numbers cannot be found using the max method. However, we can find the max of 3 numbers like below given example.

Output

This example is a part of the Java Math class tutorial with examples.

Please let me know your views in the comments section below.

About the author

Leave a Reply

Your email address will not be published.