Double.min() in Java

Double.min(): This method is available in java.lang.Double class of Java.

Syntax:

double java.lang.Double.min(double a, double b)

This method takes two arguments of type double as its parameters. This method returns the smaller of two double values.

Parameters: Two parameters are required for this method.

a: the first operand.

b: the second operand.

Returns: the smaller of a and b.

For Example:

double a = 1919.56, b = 1991.5

Double.min(a,b) = > It returns 1919.56

Approach

Java

public class DoubleMin {
    public static void main(String[] args) {

        double a = 1919.56, b = 1991.5;
        System.out.println(Double.min(a, b));

    }
}

Output:

1919.56

No comments:

Post a Comment