Difference between equals() method and == operator
807605Oct 12 2007 — edited Oct 12 2007Hi All,
This is a serious issue am facing... I need some good answers for this.
I know the difference between == operator (which compares references) and equals() method (which compares the instance values).
But, surprisingly I found in the source code of our Object class in the equals() methods implementation that its also using the same == operator to compare. Am pasting the exact implementation.
public boolean equals(Object obj) {
return (this == obj);
}
So what is the difference? Its again comparing references instead of values.
Suggestions will be highly appreciated.
Regards
Naveen