• Post Reply Bookmark Topic Watch Topic
  • New Topic

illegal start of type  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I was testing while loop, and I encountered the following errors

illegal start of type while(i!=10)

Could someone help me out, what is wrong with my codes Thanks

Here are my codes

 
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot put code like that outside a method or block.
 
Jing Liang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Keith
 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might think of it this way: A class has "state" in the form of variables, and "behavior" in the form of methods. When you want to do something -- like execute a loop -- that's behavior, so it needs to be inside a method body.
 
Jing Liang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks marc
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!