Problems with readLine() and calling methods
I'm new to the forums, and also to Java programming. I'm trying to write a Cash Till program for a project but I keep having a problem with my input.
The drawMainMenu() method does no logic; it just displays the menu. It displays, however, the two choices the user can take: "1" to go to Transactions, and "2" to Exit. The String inputStr is declared globally as a static String.
public static void main(String args)
while (inputStr != "1" && inputStr != "2")
"\nERROR: Input Out of Range." +
//DUMMY EFFECTS: This part includes what happens
// after the selection is made.
//Method to acquire input from user
static String userInput()
BufferedReader br = new BufferedReader(
inputStr = br.readLine();
catch (IOException ioe)
}//end method userInput
There seems to be nothing wrong with userInput(), 'coz the userVerify() method also calls the same method and it works just fine. At the main method, however, if I enter "1" or "2" from userInput(), it still goes through the while loop! I can't understand what's wrong. Please help!
Thanks so much in advance for any advice/comment. All suggestions are very much appreciated.