## Syntax:

public static double min(double a,double b)

## Java Code Example :

This java example source code demonstrates the use of min(double a,double b) method of Double class.

Some takeaways on this method:

• Returns the smaller of two double values as if by calling Math.min.
• since JDK 1.8
```package com.javatutorialhq.java.examples;

import static java.lang.System.out;

/*
* This example source code demonstrates the use of
* min(double a,double b) method of Double class
*/

public class DoubleMin {

public static void main(String[] args) {

Double val1 = 4.99;
Double val2 = 0.0 / 0.0;
Double val3 = 1033.0 / 0;
Double val4 = -val1 / 0.0;
Double val5 = -916445.92;
Double val6 = 0.0;

/*
* test all the possible scenario on using the
* min(double a,double b) method
* Note, this only works using java 8
*/

out.println("Smallest Between "+val1+" and "+val2+ " = "
+ Double.max(val1, val2));
out.println("Smallest Between "+val1+" and "+val3+ " = "
+ Double.max(val1, val3));
out.println("Smallest Between "+val3+" and "+val4+ " = "
+ Double.max(val3, val4));
out.println("Smallest Between "+val1+" and "+val5+ " = "
+ Double.max(val1, val5));
out.println("Smallest Between "+val2+" and "+val6+ " = "
+ Double.max(val2, val6));

}
}
```

## Sample Output :

Running the above example source code will give the following output

```Smallest Between 4.99 and NaN = NaN
Smallest Between 4.99 and Infinity = Infinity
Smallest Between Infinity and -Infinity = Infinity
Smallest Between 4.99 and -916445.92 = 4.99
Smallest Between NaN and 0.0 = NaN
```