Sunday, June 14, 2009

Java tutorial sample source code Labeled break statement

Java tutorial sample source code Labeled break statement

The labeled form of a break statement terminates an outer statement, which is identified by the label specified in the break statement. The following program searches for a value in a two-dimensional array. Two nested for loops traverse the array. When the value is found, a labeled break terminates the statement labeled search, which is the outer for loop.

Java tutorial sample source code Labeled break statement sample:

int[][] numbers = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};

int searchNum = 5;
boolean foundNum = false;

searchLabel:
for( int i=0; i

Related Post:

Java Tutorial switch statement source code

Java tutorial source code get input from keyboard

Java Tutorial Using JOptionPane to get input

Java tutorial Decision Control Structures: if statement

PHP Tutorial

Java programing source code sample printing characters

Java tutorial if-else statement

C programming sample source code: Sum of 2 numbers

Java Programming Features