Search code examples
javajava.util.scannersystem.in

I'm trying to take an input using Scanner(System.in) but it's not letting me. Help!


So I'm trying to take an input from a user using Scanner(System.in) but when i try to type something into the console it won't let me.

Can anyone help?

Function.show();

Scanner input = new Scanner(System.in);

if (input.equals("a"))
{
    Function.outputFile(1, list);
}

input.close();

Solution

  • You're forgetting to call next on the Scanner. Your if line should be if (input.next().equals("a")), instead.