NestingLoops
Code
public class NestingLoops
{
public static void main( String[] args )
{
// this is #1 - I'll call it "CN"
for ( int n=1; n <= 3; n++ )
{
for ( char c='A'; c <= 'E'; c++ )
{
System.out.println( c + " " + n );
//1.n cause c repeats itself a few times
//2.n repeats itself before changing
}
}
System.out.println("\n");
// this is #2 - I'll call it "AB"
for ( int a=1; a <= 3; a++ )
{
for ( int b=1; b <= 3; b++ )
{
System.out.println( a + "-" + b + " " );
//3. the sets are vertical and not horizontal
}
System.out.println( " Cheese with more cheez" );
//4. This causes the statement to appear after each set
// * You will add a line of code here.
}
System.out.println("\n");
}
}
NestingLoops