java.lang.StrictMath.max(double a, double b)%uA0方法返回两个double值中的那人更大的值。
如果该参数具有相同的值,其结果为相同的值。如果任一值为NaN,那么结果为NaN。
这种方法认为负零严格小于正零。如果一个参数是正零和其他负0,那么结果为正零。
声明
以下是java.lang.StrictMath.max()方法的声明
public static double max(double a, double b)
参数
-
a%uA0-- 这是一个double值
-
b%uA0-- 这是另一个double值
返回值
此方法返回a和b中的最大值。
异常
-
NA
例子
下面的例子显示java.lang.StrictMath.max()方法的使用。
package com.yiibai import java.lang.* public class StrictMathDemo { public static void main(String[] args) { double d1 = 85 , d2 = 20, d3 = -10 // both positive values double maxValue = StrictMath.max(d1, d2) System.out.println("StrictMath.max(85, 20) : " + maxValue) // one positive and one negative value maxValue = StrictMath.max(d1, d3) System.out.println("StrictMath.max(85, -10) : " + maxValue) } }
让我们来编译和运行上面的程序,这将产生以下结果:
StrictMath.max(85, 20) : 85.0 StrictMath.max(85, -10) : 85.0