早教吧 育儿知识 作业答案 考试题库 百科 知识分享

求错。总是无法编译出.class文件publicclassweather2{publicstaticvoidmain(String[]args){intx=8;switch(x){case3:case4:case5:System.out.println(x+"ThisisSpring.");break;case6:case

题目详情
求错。总是无法编译出.class 文件
public class weather2
{
public static void main(String[]args)
{
int x = 8;
switch (x)
{
case 3:
case 4:
case 5:
System.out.println(x+"This is Spring.");
break;
case 6:
case 7:
case 8:
System.out.println(x+"This is Summer.");
break;
case 9:
case 10:
case 11:
System.out.println(x+"This is Autumn.");
break;
case 12:
case 1:
case 2:
System.out.println(x+"This is Winner.");
default:
System.out.println(x+"None.");
break;
  }
}
}
▼优质解答
答案和解析
自己对比吧-------------------------把你的复制的确不行!!!我重写了一遍但是没有发现错误!代码一样哦
public class weather2 {
public static void main(String[] args) {
int x = 8;
switch (x) // 用switch实现多分支语句
{
case 3:
case 4:
case 5:
System.out.println(x + "This is Spring.");
break;
case 6:
case 7:
case 8:
System.out.println(x + "This is Summer.");
break;
case 9:
case 10:
case 11:
System.out.println(x + "This is Autumn.");
break;
case 12:
case 1:
case 2:
System.out.println(x + "This is Winner.");
default:
System.out.println(x + "None.");
break;
}
}
}