O'Reilly logo

Java™ Puzzlers: Traps, Pitfalls, and Corner Cases by Neal Gafter, Joshua Bloch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10. Advanced Puzzlers

The puzzles in this chapter concern advanced topics, such as nested classes, generics, serialization, and binary compatibility.

Puzzle 86: Poison-Paren Litter

Can you come up with a legal Java expression that can be made illegal by parenthesizing a subexpression, where the added parentheses serve only to document the order of evaluation that would take place in their absence?

Solution 86: Poison-Paren Litter

It seems that inserting a pair of parentheses serving only to document the existing order of evaluation should have no effect on the legality of a program. Indeed, this is true in nearly all cases. In two cases, however, inserting a seemingly innocuous pair of parentheses can make a legal Java program illegal. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required