math.pow int_Java Math类静态int max(int i1,int i2)示例
math.pow int
数学类静态int max(int i1,int i2) (Math Class static int max(int i1,int i2) )
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 int, it returns the largest element from the given two arguments (which are of int types).
此方法的返回类型为int ,它从给定的两个参数(均为int类型)中返回最大的元素。
In this method, we pass two integers (int) parameters as an argument.
在此方法中,我们传递两个整数( int )参数作为参数。
This method does not throw any exception.
此方法不会引发任何异常。
Syntax:
句法:
public static int max(int i1, int i2){}
Parameter(s): int i1, int i2 – two integer values, in which we have to find the largest value.
参数: int i1,int i2 –两个整数值,我们必须在其中找到最大值。
Return value:
返回值:
The return type of this method is int, it returns the largest/maximum value.
此方法的返回类型为int ,它返回最大值/最大值。
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(int i1,int i2)方法的示例 (Java program to demonstrate example of max(int i1,int i2) method)
// Java program to demonstrate the example of
// max(int i1, int i2) method of Math Classpublic class MaxIntTypeMethod {public static void main(String[] args) {// declaring variablesint i1 = -0;int i2 = 0;int i3 = -2;int i4 = 124;// displaying the valuesSystem.out.println("i1: " + i1);System.out.println("i2: " + i2);System.out.println("i3: " + i3);System.out.println("i4: " + i4);// Here , we will get (0) because we are // passing parameter whose value is (-0,0)System.out.println("Math.max(i1,i2): " + Math.max(i1, i2));// Here , we will get (124) and we are // passing parameter whose value is (0,124)System.out.println("Math.max(i2,i4): " + Math.max(i2, i4));}
}
Output
输出量
E:\Programs>javac MaxIntTypeMethod.javaE:\Programs>java MaxIntTypeMethod
i1: 0
i2: 0
i3: -2
i4: 124
Math.max(i1,i2): 0
Math.max(i2,i4): 124
翻译自: https://www.includehelp.com/java/math-class-static-int-max-int-i1-int-i2-with-example.aspx
math.pow int
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
