Java中的switch语句的用法

    欢迎使用购物管理系统

         1. 登 录 系 统

         2. 退 出

请选择,输入数字:1

    欢迎使用我行我素购物管理系统

         1. 客 户 信 息 管 理

         2. 购 物 结 算

         3. 真 情 回 馈

         4. 注 销

请选择,输入数字:

你想要问什么问题?不过感觉像那个培训机构的

再往下的内容应该怎么写?图片

int res = 0;
switch (res) {
case 1:
System.out.println("客 户 信 息 管 理");
break;
case 2:
System.out.println("购 物 结 算");
break;
case 3:
System.out.println("真 情 回 馈");
break;
default:
System.out.println("注 销");
break;
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入序号:");
int index = input.nextInt();

    switch (index) {
        case 1:
        System.out.println("客 户 信 息 管 理");
        break;
        case 2:
        System.out.println("购 物 结 算");
        break;
        case 3:
        System.out.println("真 情 回 馈");
        break;
        default:
        System.out.println("注 销");
        break;
    }
}

你也是挺傻的!

package test;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test02 {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println("请输入序号:");
    String index = input.next();

    Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
    Matcher userNameMatch = p.matcher(index + "");

    if (userNameMatch.find()){
        System.out.println("只能输入数字!");
    }else{
        switch (index) {
        case "1":
            System.out.println("客 户 信 息 管 理");
            break;
        case "2":
            System.out.println("购 物 结 算");
            break;
        case "3":
            System.out.println("真 情 回 馈");
            break;
        default:
            System.out.println("注 销");
            break;
        }
    }
}

}
这个是我优化过的

swich(){
case "":
break;
default:
break;
}

case里在套用switch case语句