File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "while loop question" Watch "while loop question" New topic

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é

Joined: Nov 24, 2005
Posts: 14687

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
Don't get me started about those stupid light bulbs.
subject: while loop question
Similar Threads
Scan a text file.
connection problem from servlet to jdbc
File Input - Null Pointer Exception
variable problem
How do i develop 10*10 table using loops