-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathLoop.java
50 lines (46 loc) · 1.05 KB
/
Loop.java
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
41
42
43
44
45
46
47
48
49
50
public class Loop {
public static void main(String[] args) {
int n = 10;
for (int i = 0; i < n; ++i) {
if (i % 2 == 1)
continue;
if (i > 0)
System.out.print(" ");
System.out.print(i);
}
System.out.println();
int i = 0;
while (i < n) {
if (i > 0)
System.out.print(" ");
System.out.print(i);
++i;
if (i > n/2) {
break;
}
}
System.out.println();
i = n - 1;
do {
System.out.println("do-while");
++i;
} while (i <= n);
i = 0;
do {
if (i > 5)
break;
if (i > 0)
System.out.print(" ");
System.out.print(i);
++i;
} while (i < n);
System.out.println();
i = 0;
for (;;) {
++i;
break;
}
for (; i == 0; );
System.out.println(i);
}
}