java math max_Java Math类静态double max(double d1,double d2)示例
java math max
數(shù)學(xué)類靜態(tài)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.
此方法用于返回方法中兩個(gè)給定參數(shù)中的最大值,換句話說(shuō),它返回給定兩個(gè)參數(shù)中的最大值。
This is a static method so it is accessible with the class name too.
這是一個(gè)靜態(tài)方法,因此也可以使用類名進(jìn)行訪問(wèn)。
The return type of this method is double, it returns the largest element from the given two arguments (which are of double types).
此方法的返回類型為double ,它從給定的兩個(gè)參數(shù)(均為double類型)中返回最大的元素。
In this method, we pass two double values parameters as an argument.
在此方法中,我們傳遞兩個(gè)雙精度值參數(shù)作為參數(shù)。
This method does not throw any exception.
此方法不會(huì)引發(fā)任何異常。
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.
參數(shù): double d1,double d2 –兩個(gè)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.
如果我們?yōu)閮蓚€(gè)參數(shù)傳遞相同的值,則它將返回相同的值。
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 variablesdouble d1 = -0.0;double d2 = 0.0;double d3 = -0.6;double d4 = 124.68;// displaying the valuesSystem.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 MaxDoubleTypeMethod d1: -0.0 d2: 0.0 d3: -0.6 d4: 124.68 Math.max(d1,d2): 0.0 Math.max(d2,d4): 124.68翻譯自: https://www.includehelp.com/java/math-class-static-double-max-double-d1-double-d2-with-example.aspx
java math max
總結(jié)
以上是生活随笔為你收集整理的java math max_Java Math类静态double max(double d1,double d2)示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c语言getchar函数_C语言中带有示
- 下一篇: 无法从ftp服务器上复制文件格式,ftp