common mistake when comparing two objects

I just needed to bring this to everyones notice. equals method in String is for comparing two strings only. Read this in fine letters since many a times, I have done the mistake of comparing two Objects and get a error or they dont get compared at all.

public boolean equals(Object anObject)

Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.

In

Leave a Reply

Your email address will not be published. Required fields are marked *