The break and continue Statements


...

for ( count = 1; count <= 10; count++ ) {

g.drawString("Breaks are silly!");

if ( count == 5 )
break; // break loop only if count == 5

g.drawString( Integer.toString( count ), xPos, 25 );
xPos += 10;

}

g.drawString( "Broke out of loop at count = " + count,
25, 40 );
}

with the following:

...

for ( count = 1; count <= 10; count++ ) {

g.drawString("Breaks within for loops are silly!");

if ( count < 5 ) {

g.drawString( Integer.toString( count ), xPos, 25 );
xPos += 10;

}

}

g.drawString( "Broke out of loop at count = " + count,
25, 40 );
}