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 is the basic concept of java?
What happens when a main method is declared as private?
22 Answers DELL, Infosys, L&T, Sun Microsystems,
How will you communicate between two applets?
What is the difference between interface & abstract class?
What is a concrete classes? Is Java object class is concrete class?
What is defined as false sharing in the context of multithreading?
Are arrays immutable in java?
How core java/j2ee project performance can be measured ?
What is the purpose of abstract class?
Which is better ascii or unicode?
What is the main function in java?
is JVM platform dependent or independent..?
11 Answers IBM, Tech Mahindra,