Untitled Document

Subscribe here to get updates on new Videos


3. Difference between "== operator" and "equals() method" in java?




previous homenext


Difference between == operater and .equals() method?

In general we use == operator for reference comparison whereas .equals() method for content comparision.


.equals() method present in object class also meant for reference comparison only based on our requirement we can override for content comparison .
In String class, all wrapper class and all collection classes .equals() method is overridden for content comparison.