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
The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of the

Dynamic JAVA Class and type information is kept around at runtime. This allows runtime loading and inspection of code in a very flexible way.


If we have 2 tables like bankcustomer(cid,cname,addr,acc_type) and customeraccount(cid,amount). How to Deposit amount into the given customer account.?

Please can you write some codes and their functions too. At least 10! Please

Project Requirements Write and test a Java program to play Minesweeper using Model-View-Presenter design (The model is an interface defining the data to be displayed or other

For this assignment we will be solving the producer-consumer problem with a bounded buffer. You are required to implement this assignment in Java. There are three components in thi

A framework is made up of the set of classes which permit us to use a library in a best possible way for a particular requirement.

What is Operator Overloading? A few object oriented languages, notably C++, permit you to not only overload techniques but also operators like + or -. This is very menaingful w

For this Assignment, submit the following program: Create an application for an animal-fur trimming service. The business is open 15 weeks of the year, from April through July. The