Thursday, November 16, 2006, 10:20:43 AM, you wrote: PP> Hi Chris,
PP> Yes, I evaluated it (eclipse 3.2.1 can do that) and used one of the PP> generated hashCode (in a hurry) but equals isn't ideal!. I wouldn't PP> touch it with a barge pole :) PP> especially this piece of code PP> if (getClass() != obj.getClass()) PP> return false; PP> See http://www.artima.com/intv/bloch17.html for a discussion PP> and too many return satements is from my point of view: abhorrent (not PP> conducive to debugging or logging if you want a justification and PP> reduced readability isn't enough of a justification). Hello Piyush, My reading is both version are valid, I prefer instanceof but there are times when getClass() is appropriate. But either way, Eclipse will also generate with instanceof: public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (!(obj instanceof Cookie)) return false; final Cookie other = (Cookie) obj; if (domain == null) { if (other.domain != null) return false; } else if (!domain.equals(other.domain)) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; if (version != other.version) return false; return true; } I don't subscribe to "a method should have a single return" principle. I rarely debug equals/hashCode instead opting to capture those cases in a testcase. -Chris -- Chris Grindstaff | http://gstaff.org

