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