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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " Consider this code." Watch " Consider this code." New topic

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

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
Gaurav Joshi

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
Don't get me started about those stupid light bulbs.
subject: Consider this code.
It's not a secret anymore!