Example
Get the lowest value from different pairs of numbers:
java
System.out.println(Math.min(2.0, 0.25));
System.out.println(Math.min(31.2f, 18.0f));
System.out.println(Math.min(14, 22));
System.out.println(Math.min(96L, 2048L));
Definition and Usage
The min() method returns the number with the lowest value from a pair of numbers.
Tip: Use the max() method to return the number with the highest value.
Syntax
One of the following:
java
public static double min(double x, double y)
java
public static float min(float x, float y)
java
public static int min(int x, int y)
java
public static long min(long x, long y)
Parameter Values
| Parameter | Description |
|---|---|
| x | Required. A number. |
| y | Required. A number. |
Technical Details
| Returns: | A double, float, int or long value representing the lowest of two numbers. |
|---|---|
| Java version: | Any |