what is the replacement for GOTO in java?
Answers were Sorted based on User's Feedback
break with label and continue with label.
1. Break with label
loop1: for (int i = 0; i < 10; i++)
{
loop2: for ( int j = 0; j < 10; j++)
{
System.out.println(i);
if( i + j > 10 )
break loop1;
}
}
2. continue with label
loop1: for (int i = 0; i < 10; i++)
{
loop2: for ( int j = 0; j < 10; j++)
{
if(i + j == 5)
continue loop1;
System.out.println(j);
}
}
| Is This Answer Correct ? | 12 Yes | 20 No |
What is an interoperable application in java ?
Explain the difference between map and flatmap stream operation?
Is Java is 100% pure OOPS? Explain?
What is the requirement of thread in java?
What are the main differences between the java platform and other platforms?
What classes of exceptions may be thrown by a throw statement?
What’s the difference between constructors and other methods?
Can we call virtual funciton in a constructor ?
Explain about method local inner classes or local inner classes in java?
What is super constructor?
Define nashorn in java8.
Can a static class have a constructor?