answersLogoWhite

0

Java supports labeled loops which allow you to break out of multiply nested loops by using the label on a break statement.

Here is an example:

FINDBIGGER:

for (i = 0; i < max1; i++)
{
for (j = 0; j < max2; j++)
{
if ( array[i] > array[j] )
break FINDBIGGER;
else if ( array[i] < array[j] )
break;
}
System.out.println("The break will end up here!");
}
System.out.println("The break FINDBIGGER will end up here!");


Note that technically this is not a goto - Java does not support gotos.

User Avatar

Wiki User

12y ago

What else can I help you with?