Endless loop
That is the cycle of condition is always true, the cycle of death is never-ending cycle.
For example: the while (to true) {}.
In the latter part of the development, will use an infinite loop scenario,
For example: We need to read the input entered by the user, but how much data the user input is not clear, can only use the death cycle, when the user does not want to enter your data, you can end the cycle, and how to end an infinite loop it, to You need to jump out of the statement.
Nested loop
The so-called nested loops, a loop means is another circulation loop. For example, there is also a for loop for loop is nested loops. = Total number of cycles cycles cycles * the outer.
Once outside the loop, the inner loop all times.
When the printing pattern, the outer loop line, the inner loop controls the column
Nested loop format:
Examples: nested loop, the rectangular print 8 5 *
public static void main (String [] args) { // rectangular 5 * 8, * print line number 5, for each row of 8 // outer 5 cycles, within 8 cycles for ( int I = 0; I <5 ; I ++ ) { for ( int J = 0; J <. 8; J ++ ) { // not a new line asterisk of System.out.print ( "*" ); } / / rear print cycle 8 the asterisk, needs a wrap System.out.println (); }
Multiplication table
public static void chengFa(){ for(int i = 1; i <= 9; i++){ for(int j = 1; j <= i; j++){ System.out.print(i + "*" + j + "=" + (i*j) + " "); } System.out.println(); } }