. 1 / * 2 for loop (with C ++) . 3 scoped variable initialization of the loop . 4 a loop, local variables initialized disappears . 5 for (initialization; condition judgment; controlled conditions) { 6 loop; 7 } . 8 . 9 while loop 10 while (determination condition) { 11 loop; 12 is } 13 is 14 do-while loop 15 to execute the loop again do, again determines whether the cycle 16 do { . 17 loop; 18 is } while (conditional) ; . 19 20 is * / 21 is public class Test { 22 is public static void main(String[] args){ 23 //for循环 24 for (int i=0;i<10;i++){ 25 System.out.println(i); 26 } 27 //System.out.println(i); 错误 28 29 //while循环 30 int i=0; 31 while(i<5){ 32 System.out.println(i); //0-4 33 i++; 34 } 35 36 //do-while循环 37 do { 38 System.out.println(i); //5-9 39 i++; 40 }while(i<10); 41 42 } 43 }