java tutorial - Java Math.min() Method - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java numbers min - Java examples - Java programs
Description
Method Math.min () - returns the minimum value of two arguments. The argument can be int, float, long, double.
Syntax
The method has the following options:
double min(double arg1, double arg2)
float min(float arg1, float arg2)
int min(int arg1, int arg2)
long min(long arg1, long arg2)click below button to copy the code. By - java tutorial - team
Options
Detailed information about the parameters:
- The method takes any primitive data type as a parameter.
Return value
- In Java, Math.min () returns the smaller of the two arguments.
Sample Code
public class Test {
public static void main(String args[]) {
System.out.println(Math.min(1.123, 1.456));
System.out.println(Math.min(2.12, 2.0));
System.out.println(Math.min(-5.2, -5.1));
System.out.println(Math.min(0, -1.1));
}
}click below button to copy the code. By - java tutorial - team
Output
1.123
2.0
-5.2
-1.1