2023.7.9
1 //选择结构 2 public class Main 3 { 4 public static void main(String[] args) 5 { 6 Scanner scanner = new Scanner(System.in); 7 System.out.println("请输入内容:"); 8 String s = scanner.nextLine(); 9 if(s.equals("Hello"))//equals判断字符串是否相等 10 { 11 System.out.println("Hello"); 12 } 13 System.out.println("end"); 14 scanner.close(); 15 } 16 } 17 18 19 public class test 20 { 21 public static void main(String[] args) 22 { 23 Scanner scanner = new Scanner(System.in); 24 String s = scanner.nextLine(); 25 switch(s) 26 { 27 case "袁天罡": 28 System.out.println("参见大帅"); 29 break; 30 case "李星云": 31 System.out.println("天暗星"); 32 break; 33 case "姬如雪": 34 System.out.println("思如雪"); 35 break; 36 default: 37 System.out.println("你干嘛"); 38 break; 39 } 40 scanner.close(); 41 } 42 }