Java Double.compareTo(Double anotherDouble)
Syntax
Double.compareTo(Double anotherDouble) has the following syntax.
public int compareTo(Double anotherDouble)
Example
In the following code shows how to use Double.compareTo(Double anotherDouble) method.
public class Main {
public static void main(String[] args) {
Double double1 = new Double(1.1);
Double double2 = new Double("1.2");
//w ww. j a v a2s. c om
System.out.println(double1.compareTo(double2));
}
}
The output: