This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes While loop execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "While loop execution " Watch "While loop execution " New topic
Author

While loop execution

Varshini Priya
Ranch Hand

Joined: Feb 17, 2008
Posts: 93

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

Joined: Jan 08, 2009
Posts: 1477
    
    6

Its a syntax error, should be

while (i < 10)

Swastik
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Yes, you have tried to reinitialize the variable i., as Swastik mentioned.



should (or could be)



or



be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

is it valid?
while (int i <..)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Swastik Dey wrote:is it valid?
while (int i <..)
Have you tried it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: While loop execution