我正在尝试为我的程序创建一个简单的菜单来读取用户输入.这是代码:
public void menu() {
String command;
System.out.println("To operate with words write: a");
System.out.println("To operate with products write: b");
System.out.print("
Give the command: ");
Scanner scanner = new Scanner(System.in);
command = scanner.nextLine();
if (command.equals("a")) {
System.out.println("
Good job! You have chosen the word program
");
System.out.println("You can only use the following commands: ");
System.out.println("exit - to exit the program");
System.out.println("add - to add a word into the map");
System.out.println("lookup - to lookup a word into the map
");
System.out.print("Give a command: ");
command = scanner.