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

Development of an application using jade agent toolkit, You need to build a...

You need to build an agent system using the JADE Toolkit that allows the lecturer of FIT5031 to broadcast their availability and arrange for consultation with students in a dynamic

I want multiplayer backgammon game, I want Multiplayer Backgammon Game P...

I want Multiplayer Backgammon Game Project Description: We want a multiplayer backgammon as short as well as long one. It should be free and on money also. The games fronted

Calculate Bill program, Notice that each row now has the type of customer a...

Notice that each row now has the type of customer and the additional data needed. calculateBill remains the same in Customer.  However, the calculateBill in Corporate will add a

Java remote method invocation (RMI) architecture, Java Remote Method Invoca...

Java Remote Method Invocation (RMI): It gives a way for a Java program on one machine to interact with objects residing in different JVMs. The important blocks of the RMI arc

Explain what is multilevel inheritance, Explain what is Multilevel Inherita...

Explain what is Multilevel Inheritance ? The Car-Motorcycle-MotorVehicle instances showed single-level inheritance. There's nothing to stop you from going next. You can describ

What are the layers of rmi architecture, There are three layers:-  a . S...

There are three layers:-  a . Stub and Skeleton layer This layer lies just under the view of the developer. This layer intercepts method calls made by the client to the inte

What is the role of fonts in java explain with example, What is the role of...

What is the role of fonts in java explain with example? You've already seen one instance of drawing text in the HelloWorldApplet program of the last chapter. You call the drawS

What is an abstract class, What is an abstract class? Abstract class mu...

What is an abstract class? Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie. you may not

Task priority and uses in scheduling, What do you mean by a task's priorit...

What do you mean by a task's priority and how can we use it in scheduling ?

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