Book review 'Java Puzzlers' is unlike any Java book we've seen before. Promising the reader an exploration of 'traps, pitfalls and corner cases', this is by turns entertaining, infuriating and downright puzzling. It is also truly illuminating, and serves to educate while it entertains. One would expect no more from the combined talents of Joshua Bloch (author of the classic Effective Java, one of our most highly recommended intermediate/advanced Java titles), and Neal Gafter (formerly of Sun and now Java evangelist at Google).
The book consists of 95 puzzles themed across ten chapters. Most puzzles consist of a small block of seemingly innocent code and a straightforward question. But the appearance of simplicity is usually deceptive and the puzzles cast a light on some quirk, trap, pitfall or ambush. Occasionally there's no code and the puzzle is for the reader to supply the code to answer the question. And, like the best puzzles, these ones grab the reader and don't let go. This is not a book that you can read passively. It's also a lot of fun.
While this isn't the sort of book that we'd recommend to the complete beginner, anyone competent with Java will find the contents engaging and challenging. Getting the right answer gives a real buzz, but even if your answers are mostly wrong you'll learn something in the process. And it's doubtful that anyone, no matter how good they are, will skate through this book and not get tripped up along the way.
There's a serious intent behind the book as well and that is it does high-light the traps that await the unwary. With frequent references back to the Java language specification and to Effective Java, this is a book that warns of suspect practices and points out the source of hard-to-find bugs and odd program behaviour. It's educational in the best sense of the word.
An appendix provides a complete listing of all the traps and pitfalls high-lighted by the puzzles, along with a word of advice on how to avoid the problem in the first place. It's good advice but not half as much fun as working through the puzzles in the first place.
Mention must also be made of the design of the book. It's put together in such a way that the solutions to the puzzles always appear over-page, so there's no chance of accidentally getting sight of the solution as you're reading the question. The book is also illustrated with optical illusions which add to the pleasure.
What more can we say? It gets a very hearty recommendation.
Title: Java Puzzlers
Authors: Joshua Bloch and Neal Gafter
Publisher: Addison Wesley