BY : ABIYYU CAKRA / XI RPL 1
public static void main(String[] args) {
int i;
for(i=0;i<10;i++)
{
System.out.println(i);
}
}
}
0
1
2
3
4
5
6
7
8
9
public static void main(String[] args) {
int i=4;
while(i>0)
{
System.out.println(i);
i--;
}
}
}
4
3
2
1
3. DO-WHILE
public class PerulanganDOWHILE {
public static void main(String[] args) {
int x=0;
do {
System.out.println(x);
x++;
}while(x<10);
}
}
5
6
7
8
9
1. FOR
public class PerulanganFOR {public static void main(String[] args) {
int i;
for(i=0;i<10;i++)
{
System.out.println(i);
}
}
}
OUTPUT :
1
2
3
4
5
6
7
8
9
2. WHILE
public class PerulanganWHILE {public static void main(String[] args) {
int i=4;
while(i>0)
{
System.out.println(i);
i--;
}
}
}
OUTPUT :
3
2
1
3. DO-WHILE
public class PerulanganDOWHILE {public static void main(String[] args) {
int x=0;
do {
System.out.println(x);
x++;
}while(x<10);
}
}
OUTPUT :
6
7
8
9
Komentar
Posting Komentar