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
What is boolean used for?
extending thread class or implementing runnable interface. Which is better? : Java thread
Why set do not allow duplicates in java?
How many types of operators are there?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is e in java?
What does java final mean?
What is literal example?
Explain the importance of finally over return statement?
How do we access static members in java?
What is the use of list in java?
Explain about interthread communication and how it takes place in java?
Mention a package that is used for linked list class in java.
Which oo concept is achieved by using overloading and overriding?
What are the two environment variables that must be set in order to run any java programs?