forked from jbloch/effective-java-3e-source-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiceRolls.java
More file actions
22 lines (17 loc) · 735 Bytes
/
Copy pathDiceRolls.java
File metadata and controls
22 lines (17 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package effectivejava.chapter9.item58;
import java.util.*;
// Same bug as NestIteration.java (but different symptom)!! - Page 213
public class DiceRolls {
enum Face { ONE, TWO, THREE, FOUR, FIVE, SIX }
public static void main(String[] args) {
// Same bug, different symptom!
Collection<Face> faces = EnumSet.allOf(Face.class);
for (Iterator<Face> i = faces.iterator(); i.hasNext(); )
for (Iterator<Face> j = faces.iterator(); j.hasNext(); )
System.out.println(i.next() + " " + j.next());
System.out.println("***************************");
for (Face f1 : faces)
for (Face f2 : faces)
System.out.println(f1 + " " + f2);
}
}