Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error

 
jioy uilo
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why error in the line after 12:
public static void main(String[] args) {
int counter = 0;
l1:
for (int i=0; i<10; i++) {
l2:
int j = 0;
while (j++ < 10) {
if (j > i) break l2;
if (j == i) {
counter++;
continue l1;
}
}
}
System.out.println(counter);
}
}
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There cannot be intervening sentences bewteen a label an the loop it marks. That is "l2:" and "int j =0" have to be swapped.
Please ident your code using UBB.
[ May 23, 2003: Message edited by: Jose Botella ]
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing more there can not be a label on a variable declaration.
 
Brian Joseph
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So where are all the legal positions for a label? In my book I only see it being applied on the same line as the loop construct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic