java.math.BigInteger.multiply(BigInteger val) 返回一個BigInteger,其值是 (this * val).
以下是java.math.BigInteger.multiply()方法的宣告
public BigInteger multiply(BigInteger val)
val - 通過此BigInteger乘以的值
該方法返回一個BigInteger物件的值是 this * val.
NA
下面的例子顯示math.BigInteger.multiply()方法的用法
package com.yiibai; 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