Java Integer - min() Method
The java.lang.Integer.min() method returns the smaller of two int values as if by calling Math.min.
Syntax
public static int min(int a, int b)
Parameters
a |
Specify the first operand. |
b |
Specify the second operand. |
Return Value
Returns the smaller of a and b.
Exception
NA.
Example:
In the example below, the java.lang.Integer.min() method returns the smaller 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 min of two int values System.out.println("min(x, y) = " + Integer.min(x, y)); } }
The output of the above code will be:
min(x, y) = 5
❮ Java.lang - Integer