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
file download from server using applet and tomcat server

Assume all the obstacles are of height 4 units and the blocks are of heights 1 (bottom), 2 (top), 1 and 2 (top) units respectively.  Complete the control() method of the RobotContr

Iterate through list of Fish. For each fish that isAlive, do the following: * * 1. If this fishIsSurroundedByRocks, DO NOTHING, and move on to the next fish. * (This f

Need Android GeoLocation Service App Project Description: I want an android service app that will run on the background. The app has to get the users location (latitude an

How do I prevent the output of my JSP or Servlet pages from being cached by the browser? Ans) You will require to set the appropriate HTTP header attributes to stop the dynamic

I am preparing ehopsital project. For the needs of hospital in that billing module and patient registration and stores module and e.t.c module is there for hospital needs. Skill

What is numeric promotion? Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place.

write a program to find the area under the curvey y=f(x) between x=a and x=b.integrate y=f(x) between the limits of a and b. the area under a curve between two points can be found

State about the performance of java First versions of java were pretty slow. Java performance has gotten a lot better with aggressive just-in-time-compiler (JIT) techniques

Ask questionWrite a program BruteForceSearch that uses the brute-force approach given above and compare its running time on your computer with that of Binary Search for largeW.txt