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.



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
Explain continue statement with example? It is sometimes essential to exit from the middle of a loop. Sometimes you'll need to begin over at the top of the loop. Sometimes you'

frequently used java array method

Question: (a) Differentiate between the following terms using suitable examples of your own:- (i) inheritance v/s composition (ii) subclass v/s superclass (iii) softwa

What is Invoking static methods If a method or field is declared static, you access it through using the class name rather than a reference to a particular example of the class

I want Hall Rental Website Project Description: I want to prepare website for my party venue where i will post the photos and detail of place along with availability calendar

A stored procedure is a set of statements/commands which reside in the database. The stored procedure is pre-compiled and keeps the database the effort of parsing and compiling sql

Project Description: I want a lot of developers to develop modules The basic purpose of this project is to prepare a standard ERP Software Company will be divided into module

Project Description: We have a project on hold to complete a due task of a Java swing desktop audio and video server. The admin panel and other features are already implemented.

In this programming assignment, you are going to implement the simple distributed ticket reservation system (DTRS) from Assignment 1 in CORBA using Java IDL. In addition to the thr