Comment on Tutorial - The equals() Method example in Java By Baski



Comment Added by : Dinesh Chopra dc

Comment Added at : 2013-03-19 04:30:48

Comment on Tutorial : The equals() Method example in Java By Baski
Hi,

I think this is not a correct defination of equals method.
According to me correct definition is that

public class Book {
...
public boolean equals(Object obj) {
if(obj == null)
return false;
if(!(this == obj))
return false
if(getClass() != obj.getClass())
return ISBN.equals((Book)obj.getISBN());
else
return false;
}
}

Sorry if it have any errors...

DC :)


View Tutorial



Subscribe to Tutorials

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

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

Java program using Method Overriding

Archived Comments

1. Hi... I used this code.But I am troubling that the
View Tutorial          By: Sandip Gurule at 2013-10-14 13:34:49

2. thanks for this example but i want the whether th
View Tutorial          By: Rupesh Chavan at 2010-03-14 07:36:31

3. Solution for javax.comm.NoSuchPortException

View Tutorial          By: Manjunath Suresh Vaidya at 2011-03-09 04:46:57

4. Your post helped me to resolve the SSH exception..
View Tutorial          By: Ashwini at 2008-07-14 12:47:32

5. pls tell me how to insert data in database .
View Tutorial          By: sankar at 2009-10-22 05:37:45

6. A more complete description of the common pitfalls
View Tutorial          By: Phil at 2012-11-25 02:06:49

7. hi,.. i have used this code to sending sms. It see
View Tutorial          By: dana at 2008-08-05 03:38:48

8. I faced an exception "java.net.connectExcepti
View Tutorial          By: Sandhya Rani Vellanki at 2010-11-15 00:39:24

9. There is 3rd Party webservices hosted over HTTPS,
View Tutorial          By: Ankur at 2012-02-24 16:49:59

10. i totally disagree with Gerardo Saldí[email protected] i
View Tutorial          By: Shivesh at 2009-09-24 23:46:42