[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:First of all, I don't check the forums when at work. Let's not bump things unless it has been 24 hours.
What is the method signature of hashCode(). Is it hashCode(Object o)? Your post seems to imply that it is. Check.
Also, I'm trying to wait until January to post the answer to see if others want to try it out.
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Stefan wrote:I've gotten rid of the "null" argument with this change.
How does that change the answer now?
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
There are three kinds of actuaries: those who can count, and those who can't.
piet wrote:What I don't understand is the constant outcome of the last four lines:
keyset contains new Boyarski2(10)? : false
valuesin map<I, B>: [Boyarski2: 1, Boyarski2: 2, Boyarski2: 3, Boyarski2: 4, Boyarski2: 5]
values contain new Boyarski(10)? : false
B(10) equals B(12)? false
No Boyarski equals any other Boyarski, no matter whether equals returns true or false. So either I made one or more programming errors, or there are things that are beyond me (probably both). Hmmm....
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
There are three kinds of actuaries: those who can count, and those who can't.
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Piet Souris wrote:Be that as it may, I checked whether two Boyarski's were equal and I get false, even when the equals method returns true in all cases. So either I made a programming error, or else something else is going on. The map part was intended to find out if the buckets were nicely filled, which they were, so the non overridden hashCode() is being used here. Still puzzled, I hoped to get some clues as to whether this hashCode(Object o) is being used somewhere, no sign of it yet.
There are three kinds of actuaries: those who can count, and those who can't.
OCPJSE8 97%,
Authorized Oracle Instructor,
OCAJSE8 Book: [url=http://igor.host/index.php/nailing-1z0-808/[/url]
Igor Soudakevitch wrote:..."Always override hashCode when you override equals."
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Stefan Evans wrote:Jeanne did say that at least one of the answers is valid if you remove the override annotation, but you have eliminated them all - just with the requirements for the equals method contract.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2