Java Reference
In-Depth Information
}
public class ChocolateCake {
public static void main(String[] args) {
System.out.println(true?false:true == true?false:true);
}
}
Solution 95: Just Desserts
If you made it this far, you don't need detailed explanations for these silly puzzles so we'll keep
them short and sweet:
A.
This program prints 1 . It suffers from an excess of punctuation. (Cancer of the semicolon?)
B.
This program prints [3, 1, 4, 1, 5, 9] on all implementations that we're aware of.
Technically, its output is undefined. Its comparator suffers from "heads I win, tails you lose"
syndrome.
C.
This program prints false . Its typographical layout does not match the precedence of its
operators. A few parentheses might help.
The lesson of this puzzle, and of this entire book, is: Don't code like my brother.
< Day Day Up >
 
 
Search WWH ::




Custom Search