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 field variable and local variable?
How can we create a thread in java?
Name the package that always imported by default?
How do you define a set in java?
where singleton classes are used in j2ee web application.can we use it for connection pooling.
Difference between Choice and a List?
What is the difference between instanceof and isinstance?
What are methods?
What do you understand by Header linked List?
Which Java operator is right associative?
What do you know about the garbage collector?
what is synchronization