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

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -