Double.max() in Java

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

Syntax:

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

This method takes two arguments of type double as its parameter. This method returns the greater of two double values.

Parameters: Two parameters are required for this method.

a: the first operand.

b: the second operand.

Returns: the greater of a and b.

For Example:

double a = 1991.5, b = 1991.119

Double.max(a,b) = > It returns 1991.5

Approach

Java

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

        double a = 1991.5, b = 1991.119;
        System.out.println(Double.max(a, b));

    }
}

Output:

1991.5

No comments:

Post a Comment