下面的代码给了我一个指向“return mon;”语句中的“m”的错误。当它在此方法开始时非常清楚地初始化时,它指出“变量 mon 可能尚未初始化”。它必须是超级简单的东西,我只是不明白!谢谢你。
public String monthName(int month)
{
String mon;
switch (month)
{
case 1:
mon = "January";
break;
case 2:
mon = "February";
break;
case 3:
mon = "March";
break;
case 4:
mon = "April";
break;
case 5:
mon = "May";
break;
case 6:
mon = "June";
break;
case 7:
mon = "July";
break;
case 8:
mon = "August";
break;
case 9:
mon = "September";
break;
case 10:
mon = "October";
break;
case 11:
mon = "November";
break;
case 12:
mon = "December";
break;
}
return mon;
}