Basic difference between equals and identity method, JAVA Programming

Assignment Help:

 

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


Related Discussions:- Basic difference between equals and identity method

Describe importing classes in java, Describe Importing Classes in java? ...

Describe Importing Classes in java? Fully qualified names such as java.net.URL are not the most convenient thing to have to type. You can use the shorter class names like URL w

Method over ridding method in java, Q. Write short on the method over riddi...

Q. Write short on the method over ridding method in java? Ans. Method over ridding and dynamic binding: We have seen that a method in a super class is inherited by its subclass

What is methods in java explain with an example, What is Methods in java ex...

What is Methods in java explain with an example? Data types aren't much use unless you can do things along with them. For this reasons classes have techniques. Fields say what

Need graphic designer and developer, My name is Myers, the project director...

My name is Myers, the project director of an online business that is scheduled to commence this summer in Nigeria. We are in the process of recruiting members to the project team a

Develop a adobe air native extension, Develop a Adobe Air Native Extension ...

Develop a Adobe Air Native Extension Project Description: We are seeking someone that must create an adobe native extension for the subsequent SDK: Develop a Adobe Air Nat

Program, write a program in java which enters name,roll #,and shows the sum...

write a program in java which enters name,roll #,and shows the sum of students english and maths marks?

Student, short Java application that stores words in an Array or ArrayList....

short Java application that stores words in an Array or ArrayList.

Relate java with C/C++, Relate Java with C/C++ Very similar C/C++ synta...

Relate Java with C/C++ Very similar C/C++ syntax, operators, etc. Core language is simpler than C++ -- no pointers, no operator overloading, and no multiple inheritance.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd