我正在制作一个披萨程序,要求用户选择披萨,大小,浇头以及他们是否要送货。但是,我遇到一个问题,我在控制台中输入了一些内容作为输入,但没有收到任何响应。我已经包含了代码。

我的代码:

    public static void main(String[] args) throws Exception {
        System.out.println("Welcome to Zayann's Pizza");
        Scanner myPizza = new Scanner(System.in);
        System.out.println("What pizza would you like? 1) cheese 2) chicken 3) beef 4) veg-- Please enter number");
        String[] pizzaSize = {"6 inch", "9 inch", "12 inch", "15 inch", "20 inch"};
        String[] pizza = {"cheese","chicken","beef","veg"};
        String pizzaOrder = myPizza.nextLine();
        if (myPizza.equals(pizza[0])) {
            System.out.println("You have selected cheese");
            System.out.println("What size would you like? 6 inch, 9 inch, 12 inch, 15 inch,20 inch-- Please enter size");
        }
    }

最佳答案

您正在尝试将扫描仪(myPizza)与字符串(pizza [0])进行比较。

以及@azro怎么说,请粘贴您的代码,而不是上传图片。

09-05 08:37