Java Integer - max() Method
The java.lang.Integer.max() method returns the greater of two int values as if by calling Math.max.
Syntax
public static int max(int a, int 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.Integer.max() method returns the greater of passed two int arguments.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating int values int x = 5; int y = 10; //printing the max of two int values System.out.println("max(x, y) = " + Integer.max(x, y)); } }
The output of the above code will be:
max(x, y) = 10
❮ Java.lang - Integer