java math.min_Java Math类静态double min(double d1,double d2)与示例

java math.min

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

  • This method is available in java.lang package.

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

  • This method is used to return the minimum one of both the given arguments or in other words this method returns the smallest value of the given two arguments.

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

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

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

  • The return type of this method is double, it returns the smallest element from the given two arguments.

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

  • This method accepts two arguments of double values.

    此方法接受两个双精度值参数。

  • This method does not throw any exception.

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

Syntax:

句法:

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

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

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

Return value:

返回值:

The return type of this method is double, it returns the smallest/minimum value.

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

Note:

注意:

  • If we pass "NaN" (Not a Number), it returns the same value i.e. "NaN".

    如果我们传递“ NaN”(不是数字),它将返回相同的值,即“ NaN”。

  • If we pass zero (-0 or 0), it returns the 0.

    如果传递零(-0或0),则返回0。

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

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

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

// Java program to demonstrate the example of 
// min(double d1, double d2) method of Math Class.

public class MinDoubleTypeMethod {
    public static void main(String[] args) {
        // declaring 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.min(d1,d2): " + Math.min(d1, d2));

        // Here , we will get (0.0) and we are passing parameter 
        // whose value is (0.0,124.68)
        System.out.println("Math.min(d2,d4):" + Math.min(d2, d4));
    }
}

Output

输出量

E:\Programs>javac MinDoubleTypeMethod.java

E:\Programs>java MinDoubleTypeMethod
d1: -0.0
d2: 0.0
d3: -0.6
d4: 124.68
Math.min(d1,d2): -0.0
Math.min(d2,d4):0.0


翻译自: https://www.includehelp.com/java/math-class-static-double-min-double-d1-double-d2-with-example.aspx

java math.min

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值