Hi I have some code for the Java console to do something when specific keys are pressed. The system inputs and stores the key as a string no bother and I can print it out to confirm it works. However the code never enters the conditional statement and instead jumps to the else every time. Here is the code:
Scanner MenuChoice = new Scanner(System.in);
Products.MenuCode = MenuChoice.next();
if(Products.MenuCode=="F")
{
//Run subprogram for finding a product.
Find.main();
}
else{
System.out.println("F - Find a Product");
System.out.println("p - Purchase a Product");
System.out.println("Q - Quit");
Scanner MenuChoice2 = new Scanner(System.in);
Products.MenuCode = MenuChoice2.next();
};
What's going wrong?