In Java, public class Main { public static void main(String[] args) { |
The most basic type of for loop, with a single condition. for (int i = 1; i <= 3; i++) { System.out.println(i); } |
A classic initial/condition/increment for loop. for (int j = 7; j <= 9; j++) { System.out.println(j); } |
A while loop without a condition will loop repeatedly until you while (true) { System.out.println("loop"); break; } |
You can also for (int n = 0; n <= 5; n++) { if (n % 2 == 0) { continue; } System.out.println(n); } } } |
Next example: If/Else.