java新人求解决"variable season might not have been initialized"public class Ifscore{\x05public static void main(String args[]){\x05\x05int month = 7;\x05\x05String season;\x05\x05switch (month){\x05\x05 case 3:\x05\x05 case 4:\x05\x05 case 5:\x0

来源:学生作业帮助网 编辑:作业帮 时间:2024/06/27 18:48:10
java新人求解决
xTn0 N\8O@@MJ-%4M^#C:E!Cdi߱/jr\L:=✫s)^ n7F}{йCmSl2`rph˖] 6n0 @934LF-vr}rTM!<.m)I`%^ĭѡ\riC 6vfh<TZ6XXXNkՆB bf HQHRT&7 GjLP::O\k l72UCeLtRvr)J*/c[h}u`eY# M|t/ܖ*ZyfΓ98WB@xTh6D8 he6U:1^AT;^~v~ ޳`Љ4ixscָb,i9ixl6 x)Ea^)

java新人求解决"variable season might not have been initialized"public class Ifscore{\x05public static void main(String args[]){\x05\x05int month = 7;\x05\x05String season;\x05\x05switch (month){\x05\x05 case 3:\x05\x05 case 4:\x05\x05 case 5:\x0
java新人求解决"variable season might not have been initialized"
public class Ifscore{
\x05public static void main(String args[]){
\x05\x05int month = 7;
\x05\x05String season;
\x05\x05switch (month){
\x05\x05 case 3:
\x05\x05 case 4:
\x05\x05 case 5:
\x05\x05 season = "Spring";
\x05\x05\x05break;
\x05\x05 case 6:
\x05 case 7:
\x05\x05 case 8:
\x05\x05\x05season = "Summer";
\x05\x05\x05break;
\x05\x05 case 9:
\x05\x05 case 10:
\x05 case 11:
\x05\x05\x05season = "Autumn";
\x05\x05\x05break;
\x05\x05 case 12:
\x05\x05 case 1:
\x05\x05 case 2:
\x05\x05\x05break;
\x05\x05default:
\x05\x05 season = "Bogus Month";
\x05\x05}
\x05\x05System.out.println("July is in the " + season+".");
\x05}
}

java新人求解决"variable season might not have been initialized"public class Ifscore{\x05public static void main(String args[]){\x05\x05int month = 7;\x05\x05String season;\x05\x05switch (month){\x05\x05 case 3:\x05\x05 case 4:\x05\x05 case 5:\x0
变量season没有被初始化,将
String season;
改为
String season=null;

String season="";
就可以了.