Java Double.compare(double d1, double d2)

Syntax

Double.compare(double d1, double d2) has the following syntax.

public static int compare(double d1,  double d2)

Example

In the following code shows how to use Double.compare(double d1, double d2) method.


public class Main {
  public static void main(String[] args) {
    Double double1 = new Double(1.1);
    Double double2 = new Double("1.2");
/*  ww w.  j a  v  a 2s. com*/
    System.out.println(Double.compare(double1,double2));

  }
}

The output:





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable