min() long in Java

min(): This method is available in the Math class of Java.

Syntax:

long java.lang.Math.min(long a, long b)

Thie method takes two arguments of type long as its parameters This method returns the smaller of two long values. That is, the result is the argument closer to the value of Long.MIN_VALUE. 

Note:

1. If the arguments have the same value, the result is that same value. 

Parameters: Two parameters are required for this method.

a: an argument.

b: another argument.

Returns: the smaller of a and b.

For Example:

Math.min(19991,181881) = > It returns 19991.

Approach

Java

public class MinLong {
    public static void main(String[] args) {

        long a = 19991, b = 181881;
        System.out.println(Math.min(a, b));

    }
}

Output:

19991

No comments:

Post a Comment