wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
I agree. Here's the link: http://aspose.com/file-tools
subject: while loop question
Similar Threads
How do i develop 10*10 table using loops
File Input - Null Pointer Exception
variable problem
Scan a text file.
connection problem from servlet to jdbc