目录

max()

该方法给出了两个参数的最大值。 参数可以是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)

以下是此方法的使用示例 -

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

当我们运行上述程序时,我们将得到以下结果 -

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