1. public class SwitchDemo3 {
    2. public static void main(String[] args) {
    3. // 需求:用户输入月份可以展示该月份的天数
    4. // 1,3,5,7,8,10,12月份是31天
    5. // 2月份是闰年29天,平年是28天
    6. // 4,6,9,11是30天
    7. int month = 7;
    8. switch (month){
    9. case 1:
    10. case 3:
    11. case 5:
    12. case 7:
    13. case 8:
    14. case 10:
    15. case 12:
    16. System.out.println(month + "是31天");
    17. break;
    18. case 2 :
    19. System.out.println(month + "月闰年是29天,非闰年是28天");
    20. break;
    21. case 4:
    22. case 6:
    23. case 9:
    24. case 11:
    25. System.out.println(month + "是30天");
    26. break;
    27. default:
    28. System.out.println("数据有误");
    29. }
    30. }
    31. }