Java Data Type Tutorial - Java Math.max(int a, int b)








Syntax

Math.max(int a, int b) has the following syntax.

public static int max(int a, int b)

Example

In the following code shows how to use Math.max(int a, int b) method.

/*  w w w.ja v a  2  s  .c o  m*/
public class Main {

   public static void main(String[] args) {

      // get two integer numbers
      int x = 12345;
      int y = 1234;

      // print the larger number between x and y
      System.out.println("Math.max(" + x + "," + y + ")=" + Math.max(x, y));

   }
}

The code above generates the following result.