Java Long - max() Method
The java.lang.Long.max() method returns the greater of two long values as if by calling Math.max.
Syntax
public static long max(long a, long b)
Parameters
a |
Specify the first operand. |
b |
Specify the second operand. |
Return Value
Returns the greater of a and b.
Exception
NA.
Example:
In the example below, the java.lang.Long.max() method returns the greater of passed two long arguments.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating long values long x = 5; long y = 10; //printing the max of two long values System.out.println("max(x, y) = " + Long.max(x, y)); } }
The output of the above code will be:
max(x, y) = 10
❮ Java.lang - Long