javaSE 3.7 Switch

来源:互联网 发布:nginx windows安装 编辑:程序博客网 时间:2024/06/03 23:36

public static void main(String[] args) {/*用户输入的数据对应的出星期。*/int week = 1;switch(week){default:System.out.println("d");break;case 1:System.out.println(week+"对应的是星期一");break;case 2:System.out.println(week+"对应的是星期二");//break;//...以此类推。 }/*季节的示例。 */int month = 13;switch(month){case 3:case 4:case 5:System.out.println(month+"月对应的是春季");break;case 6:case 7:case 8:System.out.println(month+"月对应的是夏季");break;case 9:case 10:case 11:System.out.println(month+"月对应的是秋季");break;case 12:case 1:case 2:System.out.println(month+"月对应的是冬季");break;default:System.out.println(month+"月没有对应的季节");//break;}}


原创粉丝点击