Java Puzzlers: Traps, Pitfalls, and Corner Cases
Java Puzzlers: Traps, Pitfalls, and Corner Cases by Joshua Bloch and Neal Gafter
- Binding:
- Paperback
- Number of Pages:
- 312
- ISBN:
- 032133678X
- Product Group:
- book
- Publisher:
- Addison Wesley
- Publication Date:
- July 21, 2005
- BooksForGeeks.com ID:
- 1266
Every programming language has its quirks. This book reveals the oddities of the Java programming language through programming puzzles.
Reviews for Java Puzzlers: Traps, Pitfalls, and Corner Cases
-
Another gem from Joshua and Neal
Rated out of 5 stars, March 12th, 2009
You can think of this book as the Java illusionists cookbook.
Full of examples designed to trip you up. Full of "Now you see it. Now you don't" effects. This analogy transcends from the examples to the images too. Optical overloading if you will! I really enjoy reading Joshua's books. He has a memorable style that conveys the nuances of the Java language in such a way as to be informative yet very entertaining at the same time. I thoroughly recommend this book. -
Read for fun, not to be a better programmer
Rated out of 5 stars, May 12th, 2007
Josh Bloch/Neal Gafter have a talent for giving concise coding wisdom with rock solid examples, this book is no different to Effective Java in that respect.
However, those expecting to hear coding philosophies and common pitfalls to avoid are not going to find them here. This book is about exactly what is says on the cover: corner cases. You may never encounter any of these issues in your entire Java career.
That said, the puzzles are insanely difficult and I found them very entertaining to read. There are possibly 2 or 3 puzzles in the entire book that are "cheap tricks", but the rest are all to do with subtleties in the language itself. If I had any criticism it would be that the puzzles go straight from puzzle to explanation without explicitly showing the output as an intermediary step... the author suggests that you run the programs and try to reach an explanation yourself. I tend to read books when travelling or when taking a break from the computer screen, so this was not practical for me.
If you haven't read Effective Java, I'd strongly recommend you read it first. I'd recommend this book to those that like a challenge or enjoy reading about Java subtleties. -
For Effective Java fans
Rated out of 5 stars, October 12th, 2005
Very much in the style of Effective Java, this expands on (and refers to) some of the themes in that book, so you might want to read it before this one.Java Puzzlers highlights some workings of the Java language that might trip you up, particularly when it comes to instantiating and initialising class members and fields. These are represented as small code snippets, the output of which you are expected to predict.
To be honest, as long as you follow correct Java practices (naming packages, classes, methods etc according to standards) you won't be tripped up by most of these. Personally, I have no cause to be messing about with byte and char primitives types, attempting to cast them to ints, hex, octal, or carrying out obscure bit shifting - this seems rather a low-level C-ish thing to do.
That said, there is also some sage advice, particularly about the vagaries of overloading and overriding, and the advice is collected together into an appendix for easy access. It doesn't feel quite as cohesive as EJ, though.
A special mention should go to the various optical illusions that accompany the puzzles. A lot of these I've not seen before, and several of them may cause your optic nerve to melt.
Not as essential as Effective Java, but still worth reading.

