Java Double max() Method

The max() method of Java Double class returns the double object having greater value amongst two double values. The result returned is same as by invoking Math.max() method.

Syntax

Parameters

Here, a & b are the two operands to be compared

Return value

The max() method returns the greater value amongst a and b.

Example 1

Output:

Enter first number.
67
Enter second number
89.001
Enter third number
89.0011
The Max value is: 89.0011

Example 2

Output:

Enter total number of elements
5
Enter 5 elements
90.009
98.887
67.8898
7566
77
Maximum value : 7566.0

Example 3

Output:

Enter number of elements you want.
5
Enter elements
90.009
90.00008
90
89
89.999
Descending order = 90.009,90.00008,90.0,89.999,89.0,