-
-
Save benjholla/e83bc9c8354e47a47a83757ac905903d to your computer and use it in GitHub Desktop.
Java Puzzle 5 (spot the bug if one exists)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Puzzle5 { | |
private static Random rnd = new Random(); | |
public static void main(String[] args) { | |
StringBuffer word = null; | |
switch(rnd.nextInt(2)) { | |
case 1: word = new StringBuffer('R'); | |
case 2: word = new StringBuffer('T'); | |
default: word = new StringBuffer('J'); | |
} | |
word.append("est"); | |
System.out.println(String.format("It's time for a %s.", word)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from Java Puzzlers: Traps, Pitfalls, and Corner Cases - Puzzle #23