what is the replacement for GOTO in java?

Answers were Sorted based on User's Feedback



what is the replacement for GOTO in java?..

Answer / firoz

continue

Is This Answer Correct ?    10 Yes 17 No

what is the replacement for GOTO in java?..

Answer / 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

More Core Java Interview Questions

What is the basic concept of java?

0 Answers  


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?

0 Answers  


What is the difference between interface & abstract class?

0 Answers  


What is a concrete classes? Is Java object class is concrete class?

0 Answers   Infosys,






What is defined as false sharing in the context of multithreading?

0 Answers  


Are arrays immutable in java?

0 Answers  


How core java/j2ee project performance can be measured ?

1 Answers  


What is the purpose of abstract class?

0 Answers  


Which is better ascii or unicode?

0 Answers  


What is the main function in java?

0 Answers  


is JVM platform dependent or independent..?

11 Answers   IBM, Tech Mahindra,


Categories