switch表达式里面的值使用scanner语句输入字符串类型时显示报错

为什么我switch表达式里面的值使用scanner语句输入字符串类型时显示报错


    //设当我说要吃什么时,我妈就给我买什么
    Scanner sc=new Scanner(System.in);
    System.out.println("请输入你想吃的食物:");
    String Isay=sc.nextInt();
    switch(Isay) {
    case "奶茶":
        System.out.println("喝奶茶");
        break;
    case "螺蛳粉":
        System.out.println("吃螺狮粉");
        break;
    default:
        System.out.println("吃烤串");
        break;
        
    }
    
}
}

img

String Isay=sc.nextInt(); sc.nextInt的返回值是int,你需要换成 sc.nextLine