Java.lang.StrictMath.min() 方法
描述
java.lang.StrictMath.min(long a, long b) 方法返回两个 long 值中较小的一个。 也就是说,结果是参数更接近 Long.MIN_VALUE 的值。 如果参数具有相同的值,则结果是相同的值。
声明
以下是 java.lang.StrictMath.min() 方法的声明。
public static long min(long a, long b)
参数
a − 这是 long 值。
b − 这是另一个 long 值。
返回值
此方法返回 a 和 b 中较小的一个。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.min() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
long l1 = 1327865 , l2 = 6787544, l3 = -297417;
// both positive values
double minValue = StrictMath.min(l1, l2);
System.out.println("StrictMath.min(1327865, 6787544) : " + minValue);
// one positive and one negative value
minValue = StrictMath.min(l1, l3);
System.out.println("StrictMath.min(1327865, -297417) : " + minValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
StrictMath.min(1327865, 6787544) : 1327865.0 StrictMath.min(1327865, -297417) : -297417.0

