Here is one benefit of using labels in Java:
block:
{
if(condition) break block;
}
Other uses with nested loops:
outterLoop: for(int i = 0; i < 10; i++)
{
while(condition)
{
if(someConditon) break outterLoop;
if(anotherConditon) break;
}
}
or
outterLoop: for(int i = 0; i < 10; i++)
{
while(condition)
{
if(someConditon) continue outterLoop;
if(anotherConditon) continue;
}
}
source
share