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
JDBC Assignment Banking Database System:  BankCustomer CUST_ID  CUST_NAME ADDRESS ACC_TYPE CUST_ID


How you Returning Values From Methods in java ? It's frequent meaningful to have a method return a value to the class which is known as it. This is accomplished through the ret

Explain the char data type in java? A char is a single character in which a letter, a digit, a punctuation mark, a tab, a space or something same. A char literal is a single on

.Write a programme to create a webpage that prints the name of the STUDENT database in Wide Latin font and set the subtitle with description of the STUDENT to the screen. Set the

Farm Production System Project Description: I require software that will allow me to input/record the daily production of our farm and allow me to view the data back in the o

Type casting defines treating a variable of one type as though it is another type. When up casting primitives as given below from left to right, automatic conversion happens. Bu

Payroll Calculator for Both Hourly and Commission Employees In assignment 13, we will create a payroll calculator that calculates   gross pay ,   taxes , and   net pay   fo

writing a program to find common friends with the use of array

Normal 0 false false false EN-US X-NONE X-NONE