aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes LABEL1: System.out.print( Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "LABEL1: System.out.print("HELP PLS");" Watch "LABEL1: System.out.print("HELP PLS");" New topic
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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: LABEL1: System.out.print("HELP PLS");
 
Similar Threads
labels
Please help me
pls consider this program i don't know how h value is incremented in Label1:
compile time error
Dan's Exam on Flow control