dimanche 30 octobre 2016

How to use Java Scanner import for If-Then Statement [duplicate]

This question already has an answer here:

How can you have user input a certain string and have a certain response? This is a piece of code I'm working on...

import java.util.Scanner;

public class AppetizerInformation {
    public static void main(String[] args) {
       System.out.print("Please enter an appetizer: ");
       Scanner userFoodInput = new Scanner(System.in);
       String appetizer = userFoodInput.next();
       if (appetizer = "Potato") {
            System.out.println("Good");
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire