java.lang.Math.max 和min方法

java.lang.Math.max 和min方法

Modifier and Type 方法 描述
static double max(double a, double b) 返回两个 double中的较大值。
static float max(float a, float b) 返回两个 float中的较大值。
static int max(int a, int b) 返回两个 int中的较大值。
static long max(long a, long b) 返回两个 long中的较大值。
static double min(double a, double b) 返回两个 double中的较小值。
static float min(float a, float b) 返回两个 float中的较小值。
static int min(int a, int b) 返回两个 int中的较小值。
static long min(long a, long b) 返回两个 long中的较小值。

max(double a, double b)

public class TestMax {
    public static void main(String[] args) {
        test();
    }
    //测试  max(double a,  double b)方法
    public static void test(){
        double max = Math.max(1.233, 1.2334);
        System.out.println("最大值是:"+max);
    }
}
最大值是:1.2334
原文地址:https://www.cnblogs.com/sweetorangezzz/p/12907234.html