Java.lang Package Classes

Java Long - min() Method



The java.lang.Long.min() method returns the smaller of two long values as if by calling Math.min.

Syntax

public static long min(long a,
                       long 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 example below, the java.lang.Long.min() method returns the smaller of passed two long arguments.

import java.lang.*;

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

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

The output of the above code will be:

min(x, y) = 5

❮ Java.lang - Long

5