What Does Math Max Do

What Does Math Max Do

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?

  1. public class IntegerMaxExample1 {
  2. public static void main(String[] args) {
  3. // get two integer numbers.
  4. int x = 5485;
  5. int y = 3242;
  6. // print the larger number between x and y.
  7. System.out.println(“Math.max(” + x + “,” + y + “)=” + Math.max(x, y));
  8. }
Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.