Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Integer.min() method is used to return the smaller of two int values as if by calling Math.min.

Syntax

public static int min(int a,
                      int b)

Parameters

a Specify the first operand.
b Specify the second operand.

Return Value

Returns the smaller of a and b.

Exception

NA.

Example:

In the below example, the java.lang.Integer.min() method is used to return the smaller of passed two int arguments.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating int values
    int x = 5;
    int y = 10;

    //printing the min of two int values
    System.out.println("min(x, y) = " + Integer.min(x, y));   
  }
}

The output of the above code will be:

min(x, y) = 5

❮ Java.lang - Integer