Loops in Java
Loops allow you to repeat a block of code multiple times. The most common types of loops in Java are for loops, while loops, and do-while loops.
Example code:
csharp
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
int i = 0;
while (i < 10) {
System.out.println(i);
i++;
}
int j = 0;
do {
System.out.println(j);
j++;
} while (j < 10);
No comments:
Post a Comment