java.lang.StrictMath.max(long a, long b)%uA0方法返回两个long值中的最大值。即,其结果是更接近Long.MAX_VALUE的值。如果该参数的值相同,其结果与参数的值相同。
声明
以下是java.lang.StrictMath.max()方法的声明
public static long max(long a, long b)
参数
-
a%uA0-- 这是一个long整型值。
-
b%uA0-- 这是另一个long整型值。
返回值
此方法返回a和b之间的最大值。
异常
-
NA
例子
下面的例子显示java.lang.StrictMath.max()方法的使用。
package com.yiibai import java.lang.* public class StrictMathDemo { public static void main(String[] args) { long l1 = 4355335 , l2 = 8887765, l3 = -3255697 // both positive values double maxValue = StrictMath.max(l1, l2) System.out.println("StrictMath.max(4355335, 8887765) : " + maxValue) // one positive and one negative value maxValue = StrictMath.max(l1, l3) System.out.println("StrictMath.max(4355335, -3255697) : " + maxValue) } }
让我们来编译和运行上面的程序,这将产生以下结果:
StrictMath.max(4355335, 8887765) : 8887765.0 StrictMath.max(4355335, -3255697) : 4355335.0