when loop java code example Example: for loop java for (int i = 0; i < 5; i++) { System.out.println(i); }