java - Value not initialized in if statement -


the below code has compiler error:

speedmsg might not been initialized

how can fix that?

string speedmsg;  // determine grade if (speed >= 150)   speedmsg = "stop! stop! please let me out!"; else if (speed <= 150)   speedmsg = "whew i'll walk here thanks."; 

change to:

// determine grade if (speed >= 150)     speedmsg = "stop! stop! please let me out!"; else     speedmsg = "whew i'll walk here thanks."; 

that should enough let compiler sure variable initialized.


Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -