To illustrate a practical example of the for loop, let’s create a program that counts to 100 in increments of ten.
for (int i = 0; i <= 100; i += 10) { System.out.println(i); } |
In this example, we create a program that prints only even values between 0 and 10.
for
|
In this example, we create a program that prints the multiplication table for a specified number.
int
// Print the multiplication table for the number 2
for
}
|