This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  Consider this code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " Consider this code." Watch " Consider this code." New topic
Author

Consider this code.

Sanket Modi
Ranch Hand

Joined: Mar 10, 2008
Posts: 30
Consider this code.
public class Test {
public static void main(String[] args){
for(int j = 0; j < 1 ; j++)
{
if (j < 1) continue innerLoop;
innerLoop: for(int i = 0; i < 2; i++)
{
System.out.println("Hello world");
}
}
}
}
What is the result of attempting to compile and run this.


Thanks and regards,<br />SanKet Modi
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Sanket Modi:
... What is the result of attempting to compile and run this.

Fortunately, Sun provides free tools (javac and java) for testing this.

Do you have a Java JDK installed on your machine?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Gaurav Joshi
Greenhorn

Joined: Mar 08, 2008
Posts: 18
Hi Sanket Modi,





The above code will not complie as Label are like identifiers and the statement using these label(break or continue) must be in the scope of the label
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Consider this code.
 
Similar Threads
how to create 5 objects of a class
final methods and inlining
Why this program always gets an out-of-memory error
Shadowing variable doubt?
Another question regarding the "for" loop