Difference between "== operator" and "equals() method"
== Operator: The "== operator" is used to compare primitives types and objects. While comparing primitives types like int, float, boolean "==" operator works fine. The "== operator" compare two objects based on memory reference . So "==" operator will return true, only if two references which it is comparing is pointing to the exactly same object otherwise "==" will return false. equals() Method: The equals() method has been defined in java.lang.Object class and used for comparing two objects on the basis of their contents. In java, if two objects are equal they should have equal hashcode as well. The equals() method has contract with hashcode() method in java that whenever you override equals() method you should also override the hashcode() method. Default implementation of equals() method is similar to the == operator which returns true if you are comparing two references of same object. D