Home >>Java Math Methods >Java Math.min() method
The math.min() method is an inbuilt Java method which is used to return Minimum or Lowest value from the two arguments given. The arguments in int, float, double, and long are taken up.
public static int min(int a, int b) public static double min(double a, double b) public static long min(long a, long b) public static float min(float a, float b)
a: It is used for a first value
b: It is used for a second value
This method is used to returns minimum of two numbers.
public class MyClass
{
public static void main(String args[])
{
int a = 16;
int b = 35;
System.out.println(Math.min(a, b));
}
}
public class MyClass
{
public static void main(String args[])
{
double a = 12.05;
double b = -23.34;
System.out.println(Math.min(a, b));
}
}