-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForLoop.java
More file actions
59 lines (49 loc) · 1.41 KB
/
Copy pathForLoop.java
File metadata and controls
59 lines (49 loc) · 1.41 KB
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
51
52
53
54
55
56
57
58
59
import java.util.Scanner;
public class ForLoop {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// for (inisialisasi; kondisi; updateData) {
// System.out.println("");
// }
// for (int i = 0; i <= 16; i++) {
// if (i % 2 == 0) {
// System.out.println("iterasi ke " + i + " adalah genap");
// } else {
// System.out.println("iterasi ke " + i + " adalah ganjil");
// }
// }
// int iterasi = 0;
//
// for (; iterasi < 5; iterasi++) {
// System.out.println("iterasi ke " + iterasi);
// }
// for (;;) {
// System.out.println("hehey infinite looping");
// }
// for (int i = 0; i >= 0; i++); {
// System.out.println("hehey infinite looping");
// }
// for (int i = 1; i <= 5; i++) {
// if (i == 3) {
// System.out.println("sudah capai nilai 3");
// }
//
// System.out.println(i);
// }
//
// for (int i = 1; i <= 3; i++) { // outer looping
// for (int j = 1; j <= 2; j++) { // inner looping
// System.out.println("i -> " + i + " dan j -> " + j);
// }
// }
// for (int i = 0; i < 10; i++) {
// i++;
// }
System.out.print("berapa kali looping: ");
int jumlah = input.nextInt();
for (int i = 1; i <= jumlah; i++) {
System.out.println("iterasi ke -> " + i);
}
input.close();
}
}