Answer Posted / devesh dashora
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 |
Post New Answer View All Answers
Explain the importance of thread scheduler in java?
What is an exception in java?
What is thread safe java?
What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?
Why scanner is used in java?
What is the use of pattern in java?
Explain an algorithm to find depth of a binary tree.
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
What are the rules for naming an array?
What are the advantages of autoboxing?
What modifiers may be used with a top-level class?
What is the use of string and stringbuffer?
Convert Binary tree to linked list.
What is time complexity java?
What isan abstract class and when do you use it?