目录

max()

描述 (Description)

此方法提供两个参数的最大值。 参数可以是int,float,long,double。

语法 (Syntax)

此方法有以下变体 -

double max(double arg1, double arg2)
float max(float arg1, float arg2)
int max(int arg1, int arg2)
long max(long arg1, long arg2)

参数 (Parameters)

这是参数的细节 -

  • 此方法接受任何基本数据类型作为参数。

返回值 (Return Value)

  • 此方法返回两个参数的最大值。

例子 (Example)

public class Test { 
   public static void main(String args[]) {
      System.out.println(Math.max(12.123, 12.456));      
      System.out.println(Math.max(23.12, 23.0));  
   }
}

这将产生以下结果 -

输出 (Output)

12.456
23.12
↑回到顶部↑
WIKI教程 @2018