Java.math.BigInteger.max() 方法
描述
java.math.BigInteger.max(BigInteger val) 返回此 BigInteger 和 val 的最大值。
声明
以下是 java.math.BigInteger.max() 方法的声明。
public BigInteger max(BigInteger val)
参数
val − 计算最大值的值
返回值
此方法返回 BigInteger,其值是 this 和 val 中的较大者。 如果它们相等,则可以返回任何一个。
异常
NA
示例
下面的例子展示了 math.BigInteger.max() 方法的使用。
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("123");
bi2 = new BigInteger("1000");
// assign the max value of bi1, bi2 to bi3
bi3 = bi1.max(bi2);
String str = "Maximum Value among " + bi1 + " and "+ bi2+" is "+ bi3;
// print the maximum value
System.out.println( str );
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Maximum Value among 123 and 1000 is 1000

