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



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. Thanks for this nice comparision table for Spring
View Tutorial          By: guddu at 2009-10-17 03:08:59

2. Hey..can anyone please tell me how to run linux co
View Tutorial          By: ahmed at 2008-09-05 10:22:52

3. This is very simple and easy to understand.

View Tutorial          By: satish at 2011-12-25 09:03:16

4. Thanks for the tutorial.

One questi

View Tutorial          By: Stephen at 2012-06-09 06:36:23

5. Hi VIKRAM, You cannot use your sim card number the
View Tutorial          By: Ramlak at 2007-03-29 00:38:55

6. hi friends thank you very much for the code but th
View Tutorial          By: Surya at 2008-06-13 07:06:07

7. i found this very pleasing for both my brain and m
View Tutorial          By: Matthew Redisons at 2012-10-03 14:36:32

8. Thanks this tutorial helped me :)
View Tutorial          By: Anuja at 2012-07-17 06:59:39

9. This is good for beginners.
View Tutorial          By: sathish at 2011-04-05 11:37:30

10. Hiiii Al, I am Ashraf Abu Aisheh, i am working to
View Tutorial          By: Ashraf Abu Aisheh at 2008-11-09 14:56:39