aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Loop test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Loop test" Watch "Loop test" New topic
Author

Loop test

Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10

What is the result of compiling and running the following code?

01. public class LoopTest {
02. public static void goLoop(int a) {
03.
04. start; for (int i = 1; i < 2; i++) {
05. for (int j = 1; j < 2; j++) {
06. if (a > 5) {
07. break start;
08. }
09. System.out.print(i + j);
10.
11. }
12. }
13.
14. }
15.
16. public static void main(String args[]) {
17. LoopTest.goLoop(15);
18.
19. }
20.}

The answer is compile time error.
I would like to know why. Can anybody tell me why?
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
i hope you know about the ; after start where : should have been
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Please QuoteYourSources.

Where is this question from?


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Natasha Basu
Greenhorn

Joined: Nov 21, 2008
Posts: 10
From this website

http://www.javachamp.com/public/showQuestionDetail.xhtml


And thank you for the reply. I did not look for the syntax errors.
nav katoch
Ranch Hand

Joined: May 02, 2008
Posts: 246


Thanks,

Naveen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loop test
 
Similar Threads
for loop question
why does 'break' traverse one more time
Strange result in my programm JTEST
Im having problems with writing this program :(
Thread doubt