-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhileDemo.java
More file actions
34 lines (26 loc) · 512 Bytes
/
WhileDemo.java
File metadata and controls
34 lines (26 loc) · 512 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
package control;
public class WhileDemo {
private static int num = 5;
public static void main(String[] args) throws InterruptedException {
int n = num;
while (n > 0) {
System.out.println("tick " + n);
n--;
}
for (n = num; n > 0; n--) {
System.out.println("Tick: " + n);
}
int i = 0;
for (;;) {
System.out.println(i++);
Thread.sleep(1000);
if (i > 10) {
break;
}
}
int nums[] = { 1, 2, 3, 4, 5 };
for (int j : nums) {
System.out.print(j + "\t");
}
}
}