-
Notifications
You must be signed in to change notification settings - Fork 1
/
Loops.java
40 lines (33 loc) · 849 Bytes
/
Loops.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
package com.hiwijaya.javabasic;
public class Loops {
public void forLoop(){
int n = 10;
for(int i=0; i<n; i++){
System.out.println("Iteration-" + i);
}
}
public void whileLoop(){
boolean searching = true;
int n = 0;
while(searching){
System.out.println("Searching..");
if(n == 23){
System.out.println("FOUNDED!");
searching = false;
}
n++;
}
}
public void doWhileLoop(){
do{
System.out.println("Current time divide by 3 is not 0");
}
while (System.currentTimeMillis() % 2 != 0);
}
public static void main(String[] args) {
Loops l = new Loops();
l.forLoop();
l.whileLoop();
l.doWhileLoop();
}
}