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








Syntax

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

public static int min(int a, int b)

Example

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

//w w w. j a v a2 s.c o  m
public class Main {

   public static void main(String[] args) {

      int x = 1234;
      int y = 123;

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

   }
}

The code above generates the following result.