math long取位
数学类静态long min(long l1,long l2) (Math Class static long min(long l1 , long l2) )
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 long, it returns the smallest element from the given two arguments.
此方法的返回类型为long ,它从给定的两个参数中返回最小的元素。
This method accepts two arguments of long values.
此方法接受长值的两个参数。
This method does not throw any exception.
此方法不会引发任何异常。
Syntax:
句法:
public static long min(long l1, long l2){
}
Parameter(s): long l1, long l2 – two long values, in which we have to find the smallest/minimum value.
参数: long l1,long l2 –两个长值,我们必须在其中找到最小/最小值。
Return value:
返回值:
The return type of this method is long, it returns the smallest/minimum value.
此方法的返回类型为long ,它返回最小值/最小值。
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(long l1,long l2)方法的示例 (Java program to demonstrate example of min(long l1, long l2) method)
// Java program to demonstrate the example of
// min(long l1, long l2) method of Math Class.
public class MinLongTypeMethod {
public static void main(String[] args) {
// declaring variables
long l1 = -0l;
long l2 = 0l;
long l3 = -2l;
long l4 = 12458l;
// displaying the values
System.out.println("l1: " + l1);
System.out.println("l2: " + l2);
System.out.println("l3: " + l3);
System.out.println("l4: " + l4);
// Here , we will get (0) because we are passing parameter
// whose value is (-0l,0l)
System.out.println("Math.min(l1,l2): " + Math.min(l1, l2));
// Here , we will get (-2) because we are passing parameter
// whose value is (-0l,-2l)
System.out.println("Math.min(l1,l3): " + Math.min(l1, l3));
// Here , we will get (0) and we are passing parameter
// whose value is (0l,12458l)
System.out.println("Math.min(l1,l2): " + Math.min(l2, l4));
}
}
Output
输出量
E:\Programs>javac MinLongTypeMethod.java
E:\Programs>java MinLongTypeMethod
l1: 0
l2: 0
l3: -2
l4: 12458
Math.min(l1,l2): 0
Math.min(l1,l3): -2
Math.min(l1,l2): 0
翻译自: https://www.includehelp.com/java/math-class-static-long-min-long-l1-long-l2-with-example.aspx
math long取位