这是我在if语句上的代码,但我被警告它不能返回,因为我使用了void类型,请帮助
if (BMI < 18.5)
return " You are underweight";
if ((BMI >= 18.5) && (BMI < 24.5))
return " You are normal weight.";
else if (BMI > 25)
return " You are overweight.";
else (BMI>30)
return "You are Obese!";发布于 2017-04-08 00:18:19
如果这是一个方法的一部分,你应该用返回类型String而不是void来定义它。
public String myMethod(...some args...){
your code...而不是
public void myMethod(...some args...){https://stackoverflow.com/questions/43282696
复制相似问题