This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes while loop question 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 question" Watch "while loop question" New topic
Author

while loop question

Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
Take a look at this code...



Why do I get "stuNameList variable may not have been initialized"?

How come it doesn't know it's a string?
Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129


This works!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

String stuNameList, stuName;
while {
...
stuNameList = stuNameList + "\n" + stuName;
}

stuNameList is not initialized the first time you loop, so you can't use stuNameList + "\n"


[My Blog]
All roads lead to JavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: while loop question
 
Similar Threads
Scan a text file.
How do i develop 10*10 table using loops
connection problem from servlet to jdbc
File Input - Null Pointer Exception
variable problem