BigInteger min(BigInteger val)

优质
小牛编辑
128浏览
2023-12-01

描述 (Description)

java.math.BigInteger.min(BigInteger val)返回此BigInteger和val的最小值。

声明 (Declaration)

以下是java.math.BigInteger.min()方法的声明。

public BigInteger min(BigInteger val)

参数 (Parameters)

val - 要计算最小值的值。

返回值 (Return Value)

此方法返回BigInteger,其值为此BigInteger和val的较小值。 如果它们相等,则可以返回任何一个。

异常 (Exception)

NA

例子 (Example)

以下示例显示了math.BigInteger.min()方法的用法。

package cn.xnip;
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