Programming Tutorials

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