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

Why are arrays useful in java?

0 Answers  


what is meant by Garbage collection?

0 Answers   Cap Gemini,


What is the difference between Integer and int?

10 Answers   Infosys,


Name and explain the types of ways which are used to pass arguments in any function in java.

0 Answers  


What is null data type?

0 Answers  






Is java an ide?

0 Answers  


Why is static used?

0 Answers  


Can private members of a base class are inheritable justify?

0 Answers  


Is main a keyword in java?

0 Answers  


Is nan false?

0 Answers  


What is final, finally, finalize?

0 Answers  


How many bits are in a sentence?

0 Answers  


Categories