BigInteger multiply() in Java

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

Syntax:

BigInteger java.math.BigInteger.multiply(BigInteger val)

This method takes one argument of type BigInteger as its parameter. This method returns a BigInteger whose value is (this * val).

Parameters: One parameter is required for this method.

val: value to be multiplied by this BigInteger.

Returns: this * val.

For Example:

BigInteger bigInteger = new BigInteger("1234")

BigInteger val = new BigInteger("456")

bigInteger.multiply(val)  = > It returns 562704.

Approach

Java

import java.math.BigInteger;

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

        BigInteger bigInteger = new BigInteger("1234");

        BigInteger val = new BigInteger("456");
        System.out.println(bigInteger.multiply(val));
    }
}

Output:

562704

No comments:

Post a Comment