Hi all, can anybody tell me whether it is legel or not to add label to statments other than loops.
Sachin,<P>****************************************************<BR>Learn from others mistakes. Life is too short to make all yourself.<BR>****************************************************
HI Sachin It is illegal In java You can't use label other then loop and only in for, while, switch loop, in java Continue and break are a spicial loop flow control so you can't use it another place. Outer: System.out.println("HELLO"); // 1 While(i <10) { } Above code will give compile time error. yeah but you can use it in C anc C++ at any where
Well what Himanshu was trying to convey was right but the code does compile Himanshu!! The reason is that it is not illegal to label any statement in the program. However when labels are used in conjunction with break or continue they HAVE to refer to loops and not to any statments in the program. Otherwise a compile time error occurs stating 'undefined label' [This message has been edited by Ash Rai (edited December 18, 2000).] [This message has been edited by Ash Rai (edited December 18, 2000).]
Sachin,<P>****************************************************<BR>Learn from others mistakes. Life is too short to make all yourself.<BR>****************************************************
Hi Rose In java You can't use label other then loop means (1)valid (Just only in starting of loop ) Outer: while(i <10 ) {.......} (2)illegal Outer : System.out.println("Helo"); while(i<10) {........} (3)illegal while(i<10) { Outer: System.out.println("Hello"); i++; } ------------------ "JAVA BANAYE BAVA"