·
Syntax
Public boolean equals (object
obj)
{
------
------
Return value;
}
·
Equals method in object class is public method
which returns Boolean type value. This method takes an argument of type object
·
Whenever this method is invoked on an instance,
method compares the current object with pasted object based in the address of
an object and return either true or false
·
If we compare object based on object field, then
equals method has to be override. While overriding the current object field can
be referred by using “this” keyword. The received object member should be first
downcasted then its member should be referred.
No comments:
Post a Comment