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 |
Can private class be inherited in java?
what is the difference between AWT and SWING what is the advantage of using swing?
what is servlet enginee?
how session will be expired?
Which One is optimal to choose ? Syncronized hash map or Hash table with single thread model? How can a hash map syncronized with out using syncrozed blocks in programm?
Can we write any code after throw statement?
java program with complete 4 oops concepts implemented example
What defines function?
What is the main function in java?
What is the size of arraylist in java?
Explain Public static void main?
What are the disadvantages of using inner classes?