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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. regarding 'TextMessage' and 'MessageConnection' er
View Tutorial By: gaurav at 2012-04-24 11:57:17
2. Dude, u xplaining lyk u already telling pros!Pls t
View Tutorial By: Brianjambo at 2009-04-14 06:32:13
3. really really very good
thanks all
a
View Tutorial By: bade3 at 2010-01-01 18:52:15
4. Hi,
I wann to insert data into excel file b
View Tutorial By: PRUTHVIRAJ RATHOD at 2011-05-23 11:42:14
5. About the javax.comm.* error, you need to include
View Tutorial By: Nicolas Tourne at 2011-12-18 15:11:05
6. Definitely Struts is great. I have posted an artic
View Tutorial By: Ashish at 2008-09-02 08:04:49
7. HI all i would like to send the result of " I
View Tutorial By: FLORIAN at 2011-09-14 09:04:42
8. i have an exception unknown host.
please te
View Tutorial By: saddam hussain at 2011-03-22 10:46:48
9. How to delete file button
View Tutorial By: Chinzoo at 2013-04-13 13:30:18
10. plz show me my answers
View Tutorial By: Debnita Saha at 2010-05-01 05:15:16