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. ...
Get Java™ Puzzlers: Traps, Pitfalls, and Corner Cases now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.