Answer
The == operator and equals method test different forms of equality for references. • For references, == tests whether both operands refer to the same object or are both null. • equals performs class-defined logical equality. • The default Object.equals implementation is identity equality.
Example
Code
String first = new String("Java");
String second = new String("Java");
System.out.println(first == second);
System.out.println(first.equals(second));Output
false true
Quick Revision
== checks reference identity; equals can define logical equality.