各位大神帮帮忙T_T
麻烦看看我这个哪里错? 好纠结啊!!~~
2016-08-14
1 "monday"不是字符,不能用char类型,也不能用单引号'';
2 case后面接的是值,不是变量名,应用case “monday”表示monday是字符串。
public class HelloWorld { public static void main(String[] args) { String today="monday"; switch(today){ case "monday": System.out.println("eat Baozi"); case "tuesday": System.out.println("eat Youtiao"); case "wednesday": System.out.println("eat Baozi"); case "thursday": System.out.println("eat Youtiao"); case "friday": System.out.println("eat Baozi"); case "saturday": System.out.println("eat Youtiao"); default: System.out.println("eat"); } } }
举报