Book Review: Java Puzzlers

I recently read Java Puzzlers by Joshua Bloch and Neal Gafter. I borrowed it from a coworker for a bit of leisure reading. I expected good things, since Bloch's Effective Java was excellent.

The Java content felt much more relevant and accessible than my very old printing of the C Puzzle Book. The puzzles progressively got more complex, but few really exceeded a page of code in length. A few puzzlers revolve around boring punctuation mistakes, some are misconceptions about library routines, and toward the end he's discussing more complex thread interactions. In the beginning, I was fanatically thinking through the puzzle before reading the solution, but toward the end I just didn't care anymore and proceeded right to the solution.

Since all the code samples were relatively short, they looked disturbingly like something I could write and expect I'd know how it will behave. Now I fear that I may actually have some of these puzzles represented in my own code! I'll never trust myself again. The section on arithmetic and common overflows haunts me the most -- the errors are just so silent. I think I'm smart enough to be cautious of the more complex examples when encountered in the real world.

In the end, it's an entertaining book and a quick read, and there are lessons to be learned.


Filed Under: Work Books Computers Java