The method below is called within a large loop in another method. The code has been boiled down to easily show the problem I'm having. I found that the method worked fine (prompts user for input, gets input, returns input) until I added a statement at the end of the method that closes the Scanner object. When the kb.close() statement is present, the method works the first time through, but subsequent calls to this method only display the prompt and the Scanner object never waits for the user to input anything thereafter. Can someone explain why this occurs and how to fix it?
public int scanIt()
Scanner kb = new Scanner(System.out);
System.out.print("==> "); // prompt for input
i = kb.nextInt();
System.out.println("User entered " + i);