Java Double.equals(Object obj)
Syntax
Double.equals(Object obj) has the following syntax.
public boolean equals(Object obj)
Example
In the following code shows how to use Double.equals(Object obj) method.
// w ww . j av a2s .co m
public class Main {
public static void main(String[] args) {
Double obj1 = new Double("2");
Double obj2 = new Double("2.0");
System.out.print(obj1 + " = " + obj2);
System.out.println(" ? " + obj1.equals(obj2));
obj1 = new Double("3");
obj2 = new Double("4");
System.out.print(obj1 + " = " + obj2);
System.out.println(" ? " + obj1.equals(obj2));
}
}
The code above generates the following result.