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. this total example is copy paste from the Herbert
View Tutorial          By: Parna at 2012-06-03 05:16:37

2. what if i want to create a digital signature on th
View Tutorial          By: Chandra at 2012-06-10 00:52:15

3. Hi Gaurav, The sample in this tutorial is just a c
View Tutorial          By: Ramlak at 2009-01-28 20:00:08

4. thanks. worked.
View Tutorial          By: che at 2010-03-10 11:29:10

5. I will try
View Tutorial          By: bridges at 2009-09-06 22:09:46

6. 2nd example not gud
View Tutorial          By: prakash at 2011-11-15 11:07:43

7. Just what I was looking for. Thank you.
View Tutorial          By: Babool at 2008-05-08 08:32:50

8. Thanks a ton. Was struggling to get the ListView u
View Tutorial          By: Avinash at 2012-09-25 12:25:12

9. Very nice tutorial :)

I have teste

View Tutorial          By: yannoo95170 at 2015-06-18 00:30:26

10. Excellent!!!!!!!!!!!!
View Tutorial          By: Ramana at 2009-01-02 19:31:58