The Math. max() function returns the largest of the zero or more numbers given as input parameters, or NaN if any parameter isn’t a number and can’t be converted into one.
How do you write Max in math in Java?
max(int a, int b) returns the greater of two int values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value.
How do you use the MAX function in Java?
- public class IntegerMaxExample1 {
- public static void main(String[] args) {
- // get two integer numbers.
- int x = 5485;
- int y = 3242;
- // print the larger number between x and y.
- System.out.println(“Math.max(” + x + “,” + y + “)=” + Math.max(x, y));
- }