forked from NickyBoy89/java2go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrambledForLoops.java
More file actions
40 lines (36 loc) · 1011 Bytes
/
Copy pathScrambledForLoops.java
File metadata and controls
40 lines (36 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class ScrambledForLoops {
public static void main(String[] args) {
// A completely normal for loop
System.out.println("A completely normal for loop");
for (int i = 0; i < 3; i++) {
System.out.println(i);
}
// Remove the pre-condition statement from the loop. This should not change
// how the loop behaves
int j = 0;
System.out.println("Remove the pre-condition");
for (; j < 3; j++) {
System.out.println(j);
}
// Remove the condition, this should not change behavior in this case
System.out.println("Remove the statement");
for (int i = 0; ; i++) {
if (i >= 3) {
break;
}
System.out.println(i);
}
// Remove the post-expression
System.out.println("Remove the post-expression");
for (int i = 0; i < 3; ) {
System.out.println(i);
i++;
}
System.out.println("Multiple declaration");
int e;
int f;
for (e = 1, f = 1; e < 3; e++) {
System.out.println(e);
}
}
}