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 |
Why are arrays useful in java?
what is meant by Garbage collection?
What is the difference between Integer and int?
Name and explain the types of ways which are used to pass arguments in any function in java.
What is null data type?
Is java an ide?
Why is static used?
Can private members of a base class are inheritable justify?
Is main a keyword in java?
Is nan false?
What is final, finally, finalize?
How many bits are in a sentence?