Java Double - max() Method
The java.lang.Double.max() method returns the greater of two double values as if by calling Math.max.
Syntax
public static double max(double a, double b)
Parameters
a |
Specify the first operand. |
b |
Specify the second operand. |
Return Value
Returns the greater of a and b.
Exception
NA.
Example:
In the example below, the java.lang.Double.max() method returns the greater of passed two double arguments.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating double values double x = 5.2; double y = 10.2; //printing the max of two double values System.out.println("max(x, y) = " + Double.max(x, y)); } }
The output of the above code will be:
max(x, y) = 10.2
❮ Java.lang - Double