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. Bless you, bless you, bless you! You've kept me f
View Tutorial          By: KRuthenberg at 2009-09-25 19:42:55

2. hi iam new to java i need simple java programs pls
View Tutorial          By: naga at 2010-10-06 03:45:18

3. You can also include a hidden field of the same na
View Tutorial          By: Stray at 2010-01-05 08:07:47

4. If you use comments you will have better idea abou
View Tutorial          By: Mohammed Homam at 2009-12-06 04:43:51

5. How can I send parameter to crystal report?
View Tutorial          By: Mark at 2009-10-14 03:41:36

6. Thank you. I found this very helpful.
View Tutorial          By: tavella at 2014-09-26 01:04:13

7. how can i give me a assign value to mutldimentiona
View Tutorial          By: shinde datta at 2013-01-12 10:41:15

8. i did the same thing..but it s nt working.. :(
View Tutorial          By: dEviL at 2008-12-03 10:20:31

9. import java.lang.*;
import java.io.*;

View Tutorial          By: satya at 2012-12-09 10:57:28

10. Thanks a ton Ganesh...
View Tutorial          By: Anonymous at 2012-01-25 11:20:40