I am writing a small Java console program. When I ask the user a question, they will answer with y or n. Only problem is that I can't get the program to detect which key the user pressed. Here is the code I am currently using but it isn't working. When I type y and press Enter it doesn't print anything, just another blank line and then the program exits.
Code:
System.out.println("Would you like to restart the calculator? [y/n] ");
Scanner userInput = new Scanner(System.in);
if (userInput.nextLine() == "y") {
System.out.println("yes");
}