We will see more examples later when we learn arrays and matrices.
while ( Condition ) ONEsinglestatement // While body 
for ( initialization ; Condition ; Update ) ONEsinglestatement // for body 
In other words, NEVER do this:
for ( i = 1; i < 10; i++ ) { for ( i = 1; i < 20; i++ ) { .... Same variable (i) is used in both loops... } } 
ALWAYS use different loop index variables, e.g.:
for ( i = 0; i < 10; i++ ) { for ( j = 0; j < 20; j++ ) { .... } } 
for ( j = 0; j < 10; j++) { ....(statements) } 
The following figure depicts the sequence of values that the variable j will assume when the for loop is executed:
(And we have just seen how this for loop is executed)
for ( i = 0; i < 2; i++) { for ( j = 0; j < 10; j++) { ....(statements) } } 
(And we have just seen how this for loop is executed)
(And we have just seen how this for loop is executed)
The loop condition of the outer for is not false and the outer for loop terminates  the statement pertaining to this for loop will no longer be executed (which means that the inner for loop will not be run !)
for ( i = 0; i < 2; i++) { for ( j = 0; j < 10; j++) { ....(statements) } } 

boolean isPrime; int f, n; isPrime = true; // Assume that n is prime... for ( f = 2; f <= n  1 ; f++ ) { if (n % f == 0) then isPrime = false; // Now we know n is NOT prime... } if ( isPrime ) System.out.println( n + " is a prime number"); 
boolean isPrime; int f, n, N; for ( n = 2; n <= N; n++ ) { isPrime = true; // Assume that n is prime... for ( f = 2; f <= n  1 ; f++ ) { if (n % f == 0) then isPrime = false; // Now we know n is NOT prime... } if ( isPrime ) System.out.println( n + " is a prime number"); } 