Basic difference between equals and identity method, JAVA Programming

 

The == gives true, if the variable reference points to the similar types of object in memory. That is a "shallow comparison".

 

The equals () - gives the results of running the equals() method of a user supplied class, which differentiate the attribute values. The equals() method gives "deep comparison" by comparing if two objects are logically same as opposed to the shallow comparison given by the operator ==.

If equals () function does not exist in a user supplied class then the inherited Object class's equals () method is run which evaluates if the references point to the similar object in memory. The object.equals() performs just same as the "==" operator.

Overriding the Object class may seem easy but there are many ways to get it worse, and consequence may be unpredictable behavior.

 

1309_Untitled.png

Posted Date: 7/25/2012 1:34:34 AM | Location : United States







Related Discussions:- Basic difference between equals and identity method, Assignment Help, Ask Question on Basic difference between equals and identity method, Get Answer, Expert's Help, Basic difference between equals and identity method Discussions

Write discussion on Basic difference between equals and identity method
Your posts are moderated
Related Questions
Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4



Project Description: We prepare and operate smartphone application.(Picture sharing and social networking) But there are problems in server side. It's very slow. So we

Comparable interface: The "Comparable" allows itself to compare with other same types of object. The function compareTo() is specified in the interface. Several of the standa

JMX framework can enhance the manageability of your application by  1. Monitoring your application for critical events, performance problems, and error condition statistics. E.g

An online music store offers all songs for 3$ each. The store requires members to prepay any amount of money they wish, and then download as many songs accordingly. You are require

Explain Testing for Equality with equals? That's not what you expected. To contrast strings or any other kind of object you required to use the equals(Object o) techniques from

Maintenance and Administration activities: Name                        : e-Commerce OS and Soft wares    : Websphere 6.0, IHS, Unix, Weblogic 8.1   Maintenance an

what are all possible ways in java for user input and output