/** * Demonstration of break statement * * @author TK Rogers * @version 12-15-10 */
public class BreakDemo{
public static void main ( ) {
for ( int z = 0; z < 3; z++ ) { //outer loop
for ( int x = 0; x < 10; x++ ) { // inner loop
int y = x % 3 ;
if ( y == 2 ) break ; // breaks out of inner loop
System.out.println ( "x = " + x ) ;
}
System.out.println ( ) ;
}
}
}