BigInteger max() in Java

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

Syntax:

BigInteger java.math.BigInteger.max(BigInteger val)

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

Parameters: One parameter is required for this method.

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

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

For Example:

BigInteger bigInteger = new BigInteger("1334")

BigInteger val = new BigInteger("45563")

bigInteger.max(val) = > It returns 45563.

Approach

Java

import java.math.BigInteger;

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

        BigInteger bigInteger = new BigInteger("1334");

        BigInteger val = new BigInteger("45563");
        System.out.println(bigInteger.max(val));
    }
}

Output:

45563

No comments:

Post a Comment