• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

While loop execution

 
Varshini Priya
Ranch Hand
Posts: 95
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Im trying to execute simple code and Im not able to compile it. I dont see any errors in the code.



The error that I get while Compiling is


C:\Test Java>javac Demowhile.java
Demowhile.java:7: '.class' expected
while (int i < 10)
^
Demowhile.java:12: ')' expected
}
^
2 errors

the code in line 7 & 12 looks fine. Please assist

 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a syntax error, should be

while (i < 10)
 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you have tried to reinitialize the variable i., as Swastik mentioned.



should (or could be)



or

 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it valid?
while (int i <..)
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:is it valid?
while (int i <..)
Have you tried it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic