There is a misleading (in my opinion) example code on page 563:
I claim that, because of the way in which equals() method is overriden for Dog class (Dog`s member variable - name - is String, so shouldn`t it be compared to another variable using equals() instead of ==, should it?)
The side effect is, that if we slightly change code on page 565 from:
which gives the output: "Dog key"
than the output will be: null
and we have now String constant pool issue in chapter about Collections, what isn`t even mentioned, but we read later (page 566, line 6):
In the second call to get(), the hashcodes are both 6, so step 1 succeeds. Once in the correct bucket (the "length of name = 6" bucket), the equals() method is invoked, and since Dog's equals() method compares names, equals() succeeds, and the output is Dog key.
Bert, sorry, if my tone seems to be to impertinent. My intention was only to clearly explain my doubt.
yes, all members of reference type to be compared should be checked that they are not null before they are compared. Unless the rest of the class doesn't provide that they can never be null (which is not the case in the Dog class).
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com