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. Perfectly working, and able to connect database.
View Tutorial          By: satyajit at 2012-06-01 20:16:53

2. The tutorial is very usefull, i am happy now
View Tutorial          By: Haneefa at 2013-03-30 06:31:47

3. Hi,
really nice article. but still have on

View Tutorial          By: Yogesh Rishipathak at 2009-06-04 02:25:06

4. Exception in thread "main" java.lang.NoC
View Tutorial          By: RobustTm at 2008-12-18 23:19:46

5. hi can u send me the complete working code for sen
View Tutorial          By: gautami at 2007-12-04 01:13:45

6. Hey thnx. Solved my "inconvinience" ;P
View Tutorial          By: Hesam Ossanloo at 2013-12-19 15:13:31

7. recursive programs that ask the user to enter the
View Tutorial          By: siyabonga at 2011-08-10 08:34:44

8. Hi, I second that Raghav, kindly can u email me a
View Tutorial          By: SAM at 2011-03-06 05:03:09

9. PROGRAM TO FIND OUT SMALLER NU:-

cl

View Tutorial          By: ishaan gogna at 2012-05-09 19:00:49

10. i don't know anything about computer..........
View Tutorial          By: Ami weds Pappu....... at 2013-02-14 04:00:11