| Author |
LABEL1: System.out.print("HELP PLS");
|
Ivan Ivanoff
Ranch Hand
Joined: Jan 04, 2002
Posts: 56
|
|
Hi all, This code compiles and runs just fine ... Why compiler and jvm ignores my 'LABEL1:' mark in this case ? THX. public class TestClass { public static void main(String [] sdfsdf){ for (int i=0;i<3;i++) { LABEL1: System.out.println(i); } } }
|
 |
Jamal Hasanov
Ranch Hand
Joined: Jan 08, 2002
Posts: 411
|
|
Hi Ivan, It'll work if you'll declare it outside of for(). Yes, it works and this is not strange. You can set label before anyware expecting break/continue calls. It will not ompile if you'll use this label with break. Sample: ============================= public class TestClass { public static void main(String [] sdfsdf){ //works even outside of for() LABEL1: System.out.println(1); for (int i=0;i<3;i++) { System.out.println(2); //break LABEL1;-will not compile } } } ============================ Thanx, Jamal
|
 |
Ivan Ivanoff
Ranch Hand
Joined: Jan 04, 2002
Posts: 56
|
|
THX!
|
 |
 |
|
|
subject: LABEL1: System.out.print("HELP PLS");
|
|
|