BigInteger min() in Java

min(): This method is available in java.math.BigInteger class of Java.

Syntax:

BigInteger java.math.BigInteger.min(BigInteger val)

This method takes one argument of type BIgInteger as its parameter. This method returns the minimum of this BigInteger and val.

Parameters: One parameter is required for this method.

val: value with which the minimum is to be computed.

Returns: the BigInteger whose value is the lesser of this BigInteger and val. If they are equal, either may be returned.

For Example:

BigInteger bigInteger = new BigInteger("1234")

BigInteger val = new BigInteger("3452")

bigInteger.min(val) = > It returns 1234.

Approach

Java

import java.math.BigInteger;

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

        BigInteger bigInteger = new BigInteger("1234");

        BigInteger val = new BigInteger("3452");
        System.out.println(bigInteger.min(val));
    }
}

Output:

1234

No comments:

Post a Comment