# Getting the minimum of two numbers

The static method min in the math class takes two values and determines the minimum. It can be used for integer, floats, longs and doubles:

```import java.math.*;

public class Main
{
public static void main(String args[]) throws Exception {
int    i1 = 4,     i2 = -10;
long   l1 = 234,   l2 = 235;
float  f1 = 2.2F,  f2 = 2.8F;
double d1 = 12.2D, d2 = 12.8D;

int    mini = Math.min(i1, i2);
long   minl = Math.min(l1, l2);
float  minf = Math.min(f1, f2);
double mind = Math.min(d1, d2);

System.out.println("Minimum of integers (" + i1 + ", " + i2 + ") = " + mini);
System.out.println("Minimum of longs    (" + l1 + ", " + l2 + ") = " + minl);
System.out.println("Minimum of floats   (" + f1 + ", " + f2 + ") = " + minf);
System.out.println("Minimum of doubles  (" + d1 + ", " + d2 + ") = " + mind);
}
}
```

outputs:

```Minimum of integers (4, -10) = -10
Minimum of longs    (234, 235) = 234
Minimum of floats   (2.2, 2.8) = 2.2
Minimum of doubles  (12.2, 12.8) = 12.2
```