The min() method of Integer class, returns smaller of two int numbers passed as arguments to this method. It works similar to Math.min() method.
Hierarchy:
java.lang Package
-> Integer Class
-> min() Method
Syntax of min() method
public static int min(int a, int b)
min() Parameters
a– First operand.b– Second operand.
min() Return Value
- Returns smaller number between the two int arguments
aandb.
Supported versions: Java 1.8 and onwards.
Example 1
public class JavaExample {
public static void main(String[] args) {
int a = 15, b = 6;
System.out.println("Given numbers are: "+a+", "+b);
System.out.println("Smaller of given numbers: "+Integer.min(a,b));
}
}
Output: