Java.math.BigInteger.multiply() Method

Advertisements


Description

The java.math.BigInteger.multiply(BigInteger val) returns a BigInteger whose value is (this * val).

Declaration

Following is the declaration for java.math.BigInteger.multiply() method

public BigInteger multiply(BigInteger val)

Parameters

  • val - value to be multiplied by this BigInteger

Return Value

This method returns a BigInteger object whose value is this * val.

Exception

  • NA

Example

The following example shows the usage of math.BigInteger.multiply() method

package com.tutorialspoint;

import java.math.*;

public class BigIntegerDemo {

public static void main(String[] args) {

        // create 3 BigInteger objects
        BigInteger bi1, bi2, bi3;

        bi1 = new BigInteger("7");
        bi2 = new BigInteger("20");

        // multiply bi1 with bi2 and assign result to bi3
	bi3 = bi1.multiply(bi2);

        String str = bi1 + " * " + bi2 + " = " +bi3;

	// print bi3 value
	System.out.println("Multiplication result is " +str);
    }
}

Let us compile and run the above program, this will produce the following result:

Multiplication result is 7 * 20 = 140



Advertisements
Advertisements