public class HelloWorld {
public static void main(String[] args) {
char today='日';
seich(today){
case "一":
case "三":
case "五":
System.out.println("吃包子");
break;
case"二":
case "四":
case"六":
System.out.println("吃油条");
break;
case "日":
System.out.println("吃主席套餐");
}
}
}
问题总结:
1、java关键字写错。
2、char('')、string(“”)理解不到位。
public class SwitchTest { public static void main(String[] args) { char today = '日'; switch (today) { case '一': case '三': case '五': System.out.println("吃包子"); break; case '二': case '四': case '六': System.out.println("吃油条"); break; case '日': System.out.println("吃主席套餐"); } } }
public class SwitchTest { public static void main(String[] args) { String today = "日"; switch (today) { case "一": case "三": case "五": System.out.println("吃包子"); break; case "二": case "四": case "六": System.out.println("吃油条"); break; case "日": System.out.println("吃主席套餐"); } } }
case' 一 '用单引号
seich-->switch
case "一"-->case '一':