Java max() 方法

Java 教程 · 2019-02-08 12:59:24

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 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

GWT in Action

GWT in Action

Robert Hanson、Adam Tacy / Manning Publications / 2007-06-05 / USD 49.99

This book will show Java developers how to use the Google Web Toolkit (GWT) to rapidly create rich web-based applications using their existing skills. It will cover the full development cycle, from ......一起来看看 《GWT in Action》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具