I am trying to take a user inputted string and run an if statement that checks if the user inputted string is the desired input.
However, when I run the following program I seem to always get "false" printed even when I input the desired string. I believe it has something to do with the (str == "ABCD") but I am not sure. How can I rewrite this to output "true" when the desired string is input.
Scanner keyboard = new Scanner(System.in);
String str = keyboard.nextLine(); //say the user inputs ABCD
if (str == "ABCD")
{
System.out.print(true);
} else {
System.out.print(false);
}