博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java math max_Java Math类静态double max(double d1,double d2)示例
阅读量:2527 次
发布时间:2019-05-11

本文共 2464 字,大约阅读时间需要 8 分钟。

java math max

数学类静态double max(double d1,double d2) (Math Class static double max(double d1,double d2) )

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return the maximum one of both the given arguments in the method or in other words it returns the largest value of the given two arguments.

    此方法用于返回方法中两个给定参数中的最大值,换句话说,它返回给定两个参数中的最大值。

  • This is a static method so it is accessible with the class name too.

    这是一个静态方法,因此也可以使用类名进行访问。

  • The return type of this method is double, it returns the largest element from the given two arguments (which are of double types).

    此方法的返回类型为double ,它从给定的两个参数(均为double类型)中返回最大的元素。

  • In this method, we pass two double values parameters as an argument.

    在此方法中,我们传递两个双精度值参数作为参数。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

public static double max(double d1, double d2){    }

Parameter(s): double d1, double d2 – two double values, in which we have to find the largest value.

参数: double d1,double d2 –两个double值,我们必须在其中找到最大值。

Return value:

返回值:

The return type of this method is double, it returns the largest/maximum value.

此方法的返回类型为double ,它返回最大值/最大值。

Note:

注意:

  • If we pass "NaN", it returns "NaN".

    如果我们传递“ NaN”,则返回“ NaN”。

  • If we pass the same value as both parameters, it returns the same value.

    如果我们为两个参数传递相同的值,则它将返回相同的值。

Java程序演示max(double d1,double d2)方法的示例 (Java program to demonstrate example of max(double d1, double d2) method)

// Java program to demonstrate the example of // max(double d1, double d2) method of Math Classpublic class MaxDoubleTypeMethod {
public static void main(String[] args) {
// declaring the variables double d1 = -0.0; double d2 = 0.0; double d3 = -0.6; double d4 = 124.68; // displaying the values System.out.println("d1: " + d1); System.out.println("d2: " + d2); System.out.println("d3: " + d3); System.out.println("d4: " + d4); // Here , we will get (0.0) because we are // passing parameter whose value is (-0.0,0.0) System.out.println("Math.max(d1,d2): " + Math.max(d1, d2)); // Here , we will get (124.68) and we are // passing parameter whose value is (0.0,124.68) System.out.println("Math.max(d2,d4): " + Math.max(d2, d4)); }}

Output

输出量

E:\Programs>javac MaxDoubleTypeMethod.javaE:\Programs>java MaxDoubleTypeMethodd1: -0.0d2: 0.0d3: -0.6d4: 124.68Math.max(d1,d2): 0.0Math.max(d2,d4): 124.68

翻译自:

java math max

转载地址:http://ujtzd.baihongyu.com/

你可能感兴趣的文章
HDU5447 Good Numbers
查看>>
08.CXF发布WebService(Java项目)
查看>>
java-集合框架
查看>>
RTMP
查看>>
求一个数的整数次方
查看>>
点云PCL中小细节
查看>>
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>
CMU Bomblab 答案
查看>>
微信支付之异步通知签名错误
查看>>
2016 - 1 -17 GCD学习总结
查看>>
linux安装php-redis扩展(转)
查看>>
Vue集成微信开发趟坑:公众号以及JSSDK相关
查看>>
技术分析淘宝的超卖宝贝
查看>>
i++和++1
查看>>
react.js
查看>>