Sep 19, 2024
if
statement.
while (condition) {
// code to be repeated
}
while (true)
.int a = 0;
while (a < 100) {
System.out.println(a);
a++;
}
System.out.println("Loop finished");
for (initialization; condition; increment/decrement) {
// code to be executed
}
for (int a = 0; a < 100; a++) {
System.out.println(a);
}
a += 2
to skip numbers.do {
// code to be executed
} while (condition);
int a = 10;
do {
System.out.println("Hello World");
} while (a < 10);
a < 10
is false.Understanding these loops allows for creating dynamic and flexible Java programs.