在 Java 中的 userInput 函数中,任何人都可以输入任何内容,无论如何我可以将其限制为 2 个选项。这是我的代码
import java.util.Scanner;
public class Intelijence {
public static void main(String[] args) throws InterruptedException {
Scanner playerInput;
playerInput = new Scanner(System.in);
String Question1;
System.out.println("Ugh, I need some coffee");
Thread.sleep(1000);
System.out.println("'What kind of coffee should he drink'");
Question1 = playerInput.nextLine();
System.out.println(Question1);
}
}
那么如何将选项设置为浅烤或深烤?