Could you please tell me the different between String.equals and the equals of Object Class, if both are same then
why we have equals method in String class we can use equals method of object class.
Hint: Equals is used for comparing instances of things. Think about what it means for two Object instances to be equal, and what it means for two String instances to be equal.
Thank you for reply, both are checking the content are equals right then we will go for equals of object class instead of string.equals to check the string object
santhosh kumar vk wrote:then we will go for equals of object class instead of string.equals to check the string object
I don't understand what you mean by this? You don't get to choose.
But yes, Object has an .equals() method, as does String. The are different for good reason. Pretty much all you need to know about the == operator and .equals() method in relation to Strings can be found in this CodeRanch FAQ article