1. DoWhile
public class DoWhile {
public static void main(String[] args) {
int value = 1;
do {
System.out.println("Angka : " + value);
value++;
} while (value <= 10);
}
}
2. While
public class While {
public static void main(String[] args) {
int value = 1;
while (value <= 10) {
System.out.print("Angka : " + value);
value++;
System.out.print("\n");
}
}
}
2. For
public class For {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
System.out.println("Angka : " + i);
}
}
}
3. For Bersarang
public class ForBersarang {
public static void main(String[] args) {
int a = 5;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= i; j++) {
System.out.print("*");
}
System.out.println("");
}
}
}