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 |
when you will synchronize a piece of your code? : Java thread
Can a class be subclass of itself?
What is the console in java?
How to compare two strings in java program?
Tell me the Importent classes in net package?
What is meant by 'Class access modifiers'?
Is delete, next, main, exit or null keyword in java?
how many types of Inheritance?
can any body tell me? does advance java and j2ee both are same.
System.out & System.in are final static data member of System class but we can change there reference through setOut() & setIn() method how...
What are the latest versions in JAVA related areas?
What is the primitive type short?