Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Javin @ eclipse remote debugging

Comment Added at : 2011-04-09 06:50:44

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
Here is my approach for writing equals() method from <a href="http://javarevisited.blogspot.com/2011/02/how-to-write-equals-method-in-java.html">How to write equals method in Java</a>

1) Do this check -- if yes then return true.
2) Do null check -- if yes then return false.
3) Do the instanceof check if instanceof return false than return false
4) Type cast the object; note the sequence instanceof check must be prior to casting object.
5) Compare individual attribute start with numeric attribute because comparing numeric attribute is fast and using short circuit operator so if first field does not match , don't try to match rest of attribute and return false.


View Tutorial



Related Tutorials

Java program to get location meta data from an image

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Archived Comments

1. thanks a lot............
View Tutorial          By: mks at 2013-01-03 06:50:05

2. EJB's can be deployed on multiple servers and when
View Tutorial          By: Tomek at 2011-09-12 12:29:07

3. hi i am new to JSP wht is class.forname in the cod
View Tutorial          By: chanti at 2011-05-07 03:02:26

4. Hi

Anybody plz send me the sms send

View Tutorial          By: Venky at 2008-11-19 08:33:22

5. I like your explanition its very uesfull
View Tutorial          By: Salah Mohamed at 2011-12-10 15:47:27

6. while i am executing this program i am getting Nul
View Tutorial          By: Seema at 2013-11-26 18:39:15

7. DOWNLOAD IT
View Tutorial          By: KUSUM at 2010-02-02 23:48:50

8. Awesome work! Ramlak, thank you for your help!
View Tutorial          By: ico at 2011-03-21 04:23:11

9. The !isset() is basically checking if the string i
View Tutorial          By: Bijan at 2012-09-21 20:49:41

10. Hi,

How to implement this 5 files i

View Tutorial          By: Yanosh at 2009-07-16 06:00:14