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. its superb
View Tutorial          By: chotu jain at 2011-05-24 08:47:22

2. Can you help me input 15 states and capitals in 2
View Tutorial          By: Hardik Negandhi at 2015-06-24 11:18:51

3. i like this a lot
View Tutorial          By: raj at 2011-05-06 06:15:36

4. Small modification.
System.out.println(&qu

View Tutorial          By: Rohit at 2012-02-07 16:22:52

5. hello after working with this code i got the follw
View Tutorial          By: Tapaswini Sabat at 2011-11-05 12:43:49

6. Thanx!!!!....
It helped me to startup with

View Tutorial          By: RAJITHA REDDY at 2011-03-01 02:47:03

7. java is new for me..... since i dont know from bas
View Tutorial          By: m.padma at 2011-08-08 15:40:23

8. sir can this be the role of java in internet if no
View Tutorial          By: shantanu khanduri at 2012-05-28 07:00:11

9. can i add new language for my freetts project ? I'
View Tutorial          By: [email protected] at 2011-08-09 06:49:52

10. Thanks to OP and Zarno for finishing off this code
View Tutorial          By: Soapy Balls at 2011-05-27 05:26:13