Java max() 方法

返回到:Java Number类

max() 方法用于返回两个参数中的最大值。

语法

该方法有以下几种语法格式:

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

参数

该方法接受两个原生数据类型作为参数。

返回值

返回两个参数中的最大值。

实例

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

编译以上程序,输出结果为:

18.456
23.12

返回到:Java Number类

作者:terry,如若转载,请注明出处:https://www.web176.com/java_api/19732.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2023年5月6日
下一篇 2023年5月6日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注