Questions tagged [labelled-break]
6 questions
18
votes
10 answers
Break in nested for loops
Possible Duplicate:
How to Break from main/outer loop in a double/nested loop?
I have the following situation:
for(int i = 0; i < schiffe.length-1; i++){
if(schiffe[i].schaden){
schlepper.fliege(schiffe[i].x,
…

DarkLeafyGreen
- 69,338
- 131
- 383
- 601
7
votes
9 answers
how can we go out from 4 inner for loops?
Hi
I am beginner in java and my program has 4 for loops:
my program works like this that if b is true ,the element will be removed from pointList and n will be n-- and the I want to go out from all for loops and come again from the first for loop…

user472221
- 3,014
- 11
- 35
- 42
1
vote
3 answers
Break Label is missing even when the label is inside the enclosing loop
Can someone tell me why the compiler says the label is missing in the below code:
CASE1:
Error: Label is missing
void crazyLoop() {
int c = 0;
JACK: while (c < 8) {
JILL: System.out.println(c);
if (c > 3)
break…

v1shnu
- 2,211
- 8
- 39
- 68
1
vote
3 answers
Idiomatic way of exiting from multiple nested loops?
The MATLAB documentation describes the break keyword thus:
break terminates the execution of a for or while loop. Statements in the loop after the break statement do not execute.
In nested loops, break exits only from the loop in which it occurs.…

jub0bs
- 60,866
- 25
- 183
- 186
1
vote
2 answers
Labelled "continue" doesn't seem to work
Just started learning java and I can't understand what's wrong with my code. PrimeIterator is supposed to generate infinite amount of prime numbers (starting from a number 3) but when I print the output I get: 3, 5, 7, 9, 11, 13, 15 etc.
public…

matt-pielat
- 1,659
- 3
- 20
- 33
0
votes
2 answers
I put a loop break in java at the start of loop block and not before the loop keyword. Is that common or would it bring unexpected results?
I will show you my submitted assignment's answer to give the idea of it
void chkbnch()
{
System.out.println("\n The students under notice period are =>\n\n");
for(int i=0;i<25;i++)
**ol:{**
int cnm=0;
int cnm2=0;
…

Himanshu Panchal
- 23
- 3