java.lang.Double compare(double d1,double d2)


public static int compare(double d1,double d2)

Java Code Example :

This java example source code demonstrates the use of compare(double d1,double d2) method of Double class.

Some takeaways on this method:

  • Compares the two specified double values. The sign of the integer value returned is the same as that of the integer that would be returned by the call: new Double(d1).compareTo(new Double(d2)).
  • the value 0 if d1 is numerically equal to d2; a value less than 0 if d1 is numerically less than d2; and a value greater than 0 if d1 is numerically greater than d2.
  • Since JDK 1.4
  • Must be invoked statically.

Sample Output :

Running the above example source code will give the following output

Suggested Reading List :

References :