[Solved] Number generated randomly ? and problem here with the 2nd if statement? [duplicate]


In this block (And the other if block):

 if(T >= 1 && T <= 5)
    Integer.toString(T);
    return "Fast_Plod";

You forgot brackets, so the return is always executed, resulting in the rest of the code in the method being dead code (code that can never be reached). Indentation means nothing in java, so you have to specify that the return statement is within the if block by surrounding it, and all the other lines that should be in the if block, with brackets. Also the lines Integer.toString(T); do nothing. Lastly, T can be a number greater than 7, so you must specify a return for this too.

To fix this simply add brackets:

if(T >= 1 && T <= 5) {
    return "Fast_Plod";
}
if(T >= 6 && T <= 7) {
    return "Slow_Plod";
}
else {
    return "";  //return what you want to return if it's > 7
}

7

solved Number generated randomly ? and problem here with the 2nd if statement? [duplicate]