Early last week I came home and discovered a heavy envelope from FedEx waiting for me. I opened it and found a book—Java Puzzlers. To say I was surprised would be an understatement, as I hadn’t ordered it and in fact had never heard of it. Tucked inside the front cover was a note from the publisher saying the book had been sent with the compliments of the authors for my help on the project. My help? What help? The light finally went on when I found my name in the acknowledgements crediting me with puzzle 59. Back in 2002 I attended JavaOne (with Alex and Matt) and went to a great session about Java brainteasers. At its close, Bloch invited the audience to send in other puzzles for future talks; I sent him a couple. He used one of my ideas, and three years later he not only remembered this but sent me a gratis copy! Great guy, that Joshua Bloch!
I’ve always been interested in the trivia and minutiae around software technologies, and this book doesn’t disappoint. It is filled with tricks and obfuscations that can be found within the Java programming language. Things like, “When is i != i
true?” [Click for answer ] I always learn more about how a language really works from something like this instead of a more traditional guide; it makes me think more and I seem to retain the knowledge longer. Even better, along with the soution is a lesson describing how to avoid the pitfall in your everyday coding. Good stuff.
Besides the puzzles themselves, a lot of thought went into this publication. There are optical illusions between each quandary, reflecting the misdirection that is the theme of the book. The title of each puzzle has an amusing name, many of which include hints as to the nature of the trick as well (my favorite: It’s Absurd, It’s a Pain, It’s Superclass!). Also, the layout is designed so that a puzzle always ends on the bottom of a right-facing page and so the answer is hidden from view reducing the temptation to cheat. Smart.
This book is filled with brainteasers about the Java programming language and its core libraries.