- Java.math 包的其他内容
- Java.math - 枚举
- Java.math - 讨论
Java.math.BigInteger.min() 方法
描述
java.math.BigInteger.min(BigInteger val) 返回该 BigInteger 和 val 的最小值。
声明
以下是 java.math.BigInteger.min() 方法的声明。
public BigInteger min(BigInteger val)
参数
val - 用于计算最小值的数值。
返回值
此方法返回一个 BigInteger,其值是该 BigInteger 和 val 的较小值。如果它们相等,则可以返回其中任意一个。
异常
无
示例
以下示例显示了 math.BigInteger.min() 方法的用法。
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 min value of bi1, bi2 to bi3
bi3 = bi1.min(bi2);
String str = "Minimum Value among " + bi1 + " and "+ bi2+" is "+ bi3;
// print the minimum value
System.out.println( str );
}
}
让我们编译并运行上述程序,这将产生以下结果 −
Minimum Value among 123 and 1000 is 123
java_math_biginteger.htm
广告