min(): This method is available in the Math class of Java.
Syntax:
int java.lang.Math.min(int a, int b)
This method takes two arguments of type int as its parameters. This method returns the smaller of two int values. That is the result of the argument closer to the value of Integer.MIN_VALUE.
Note:
1. If the arguments have the same value, the result is that same value.
Parameters: Two parameters are required for this method.
a: an argument.
b: another argument.
Returns: the smaller of a and b.
For Example:
Math.min(19,18) = > It returns 18.
Approach
Java
public class MinInt {public static void main(String[] args) {int a = 19, b = 18;System.out.println(Math.min(a, b));}}
Output:
18
No comments:
Post a Comment