• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loop test

 
Natasha Basu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hope you know about the ; after start where : should have been
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources.

Where is this question from?
 
Natasha Basu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks,

Naveen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic