1 //jdk7.0中switch可以使用字符串做条件 2 public class TestSwitch02 { 3 public static void main(String[] args){ 4 String a = "向良峰"; 5 6 switch(a){//JDK 7的新特性,表达式可以是字符串! 7 case "哔哩哔哩": 8 System.out.println("输入的是哔哩哔哩"); 9 break; 10 case "斩妹之瞳": 11 System.out.println("input is red eye"); 12 break; 13 case "向良峰": 14 System.out.println("输入的是XLF"); 15 break; 16 default: 17 System.out.println("hello everyone"); 18 break; 19 20 21 } 22 23 24 } 25 26 }