This question already has an answer here:
- How do I compare strings in Java? 23 answers
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