Java.math.BigInteger.multiply() 方法



說明

java.math.BigInteger.multiply(BigInteger val) 返回值的 (this * val) 的 BigInteger。

宣告

下面是 java.math.BigInteger.multiply() 方法的宣告。

public BigInteger multiply(BigInteger val)

引數

val − 要乘以該 BigInteger 的值。

返回值

此方法返回值的為 this * val 的 BigInteger 物件。

異常

不適用

示例

以下示例演示了 math.BigInteger.multiply() 方法的用法。

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);
   }
}

讓我們編譯並執行以上程式,這將產生以下結果 −

Multiplication result is 7 * 20 = 140
java_math_biginteger.htm
廣告
© . All rights reserved.