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 are the differences between Java 1.0 and Java 2.0?
What are the notations in Java?
Is ++ operator is thread safe in java?
Can we extend a class with private constructor?
What is a ?
can we access the method of class without creating the object of the class
Which method must be implemented by all threads?
How big is a pointer?
What is static variable with example?
Explain some best practices you would apply while using collection in java?
What are the four pillars of java?
What are the different ways of implementing thread? Which one is more advantageous?