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 meant by 'bit masking' in java?

0 Answers   DELL,


What is 3-tier model?

3 Answers   Wipro,


Which class should you use to obtain design information about an object

2 Answers  


What are the types of statement? explain

1 Answers   SysBiz,


Memory management in JAVA

3 Answers   Wipro, Tech Mahindra,






What are the kinds of polymorphism?

0 Answers  


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

0 Answers  


Explain java coding standards for variables ?

0 Answers  


Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what the name should i provide to the file ,in what file name should i run the program? Ple Explain

9 Answers   Infosys, TCS, DNS,


Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?

0 Answers  


What are Interceptors?

1 Answers  


what are the purposes of native, transiant key words?

2 Answers  






Categories