package com.lovecoding.J20250518; /** * @author WanJl * @version 1.0 * @title Demo09 * @description switch语句 * @create 2025/5/18 */ public class Demo09 { public static void main(String[] args) { /* switch(变量){ case 常量1: 语句1; break; case 常量2: 语句2; break; case 常量3: 语句3; break; ..... default: 语句n; } switch使用的类型可以是byte、short、int、char、String */ String a="星期一111"; switch (a){ case "星期一": System.out.println("今天星期一"); break; case "星期二": System.out.println("今天星期二"); break; case "星期三": System.out.println("今天星期三"); break; case "星期四": System.out.println("今天星期四"); break; case "星期五": System.out.println("今天星期五"); break; case "星期六": System.out.println("今天星期六"); break; case "星期日": System.out.println("今天星期日"); break; default: System.out.println("不知道..."); } } }