Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Android Security Essentials Live Lessons this week in the Android 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: 1449
    
    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: 1449
    
    6

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

Joined: Oct 13, 2005
Posts: 38033
    
  22
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
 
Similar Threads
Converting Number to Word
read next byte
Dice probability program, using nested loops.
Need help in data displaying
LinkedHashMap - trying to use the method removeEldestEntry