Advertisement
|
Kevin IM-ed me yesterday with the following question:
How come foo.getBar() == expectedBar is true yet foo.getBar().equals(expectedBar) is false?
I'll make that today's Java quiz: Have you encountered a situation in non-play code where obj1 == obj2 is true yet obj1.equals(obj2) is false?
By non-play code I mean a code base where all equals() and hashCode() overrides honor their contracts. In other words, there are no silly code like
public void equals(Object other) {
return false;
}
Read: Friday Java Quiz: Object Identity