forked from WegraLee/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
23 lines (18 loc) · 797 Bytes
/
Copy pathDiceRolls.java
File metadata and controls
23 lines (18 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package effectivejava.chapter9.item58;
import java.util.*;
// 코드 58-5 같은 버그, 다른 증상! (349쪽)
public class DiceRolls {
enum Face { ONE, TWO, THREE, FOUR, FIVE, SIX }
public static void main(String[] args) {
// 같은 버그, 다른 증상!
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);
}
}