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 |
Explain about fail safe iterators in java?
Can an unreferenced object be referenced again?
Difference between static binding and dynamic binding?
What is java used for?
What is arrays aslist in java?
Differentiate between the constructors and methods in java?
Which class is the superclass of all classes?
What is synchronization and why is it important in java programming?
Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.
What modifiers are used with a top level class?
What is a Java switch statement, and how can it be used?
In how many ways we can create threads in java?