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
Im receiving an error message of Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at Homework.main(Homework.java:51)

Question 1 Describe any five buzz words in Java Question 2 Describe exception classes and also explain common exceptions in java Question 3  Describe primitive and

The last exercise of each assignment will be continuous from assignment to assignment and will have the goal of building an e-store website by the end of the course. Date & Tim

what is methods override?

Write a program on Filling Rectangles ? The drawRect() method draws an open rectangle, a box if you prefer. If you need to draw a filled rectangle, use the fillRect() method. O

What is object oriented programming language? In classic, procedural programming you try to form the real world problem you're attempting to solve fit a few, predetermined data

I need PS1 emulator for android Project Description: There is an open source app called psx4droid i need a developer to solve problems and bugs and doing performance improvem

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'

A pointcut is something that describes at what joinpoints an advice should be applied. Advices can be applied at any joinpoint that is supported by the AOP framework. These Pointcu

Search on column demonstration in Semantic Vector Project Description: I am preparing a research on Semantic Vectors. But I am not able to check out in a vector representa