Java.lang.StrictMath.max() Method
Advertisements
Description
The java.lang.StrictMath.max(long a, long b) method returns the greater of two long values. That is, the result is the argument closer to the value of Long.MAX_VALUE. If the arguments have the same value, the result is that same value.
Declaration
Following is the declaration for java.lang.StrictMath.max() method
public static long max(long a, long b)
Parameters
a -- This is the long value.
b -- This is another long value.
Return Value
This method returns the larger of a and b.
Exception
NA
Example
The following example shows the usage of java.lang.StrictMath.max() method.
package com.tutorialspoint;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
long l1 = 4355335 , l2 = 8887765, l3 = -3255697;
// both positive values
double maxValue = StrictMath.max(l1, l2);
System.out.println("StrictMath.max(4355335, 8887765) : " + maxValue);
// one positive and one negative value
maxValue = StrictMath.max(l1, l3);
System.out.println("StrictMath.max(4355335, -3255697) : " + maxValue);
}
}
Let us compile and run the above program, this will produce the following result:
StrictMath.max(4355335, 8887765) : 8887765.0 StrictMath.max(4355335, -3255697) : 4355335.0