how to close the input when using .hasNext () in java? [closed]

-2

I'm using a code that uses Scanner (which I named input ) and uses while(input.hasNextLine()) , but it does not stop asking for entries, I know it has a specific command for it (something like /n ) but I can not remember.

Could anyone help me?

    
asked by anonymous 14.05.2018 / 03:11

1 answer

0

Hello, you can do something like this:

Scanner ler = new Scanner(System.in);
//seu código de entrada
if (ler.equals("")) {
        ler.close();
    }   
}
    
14.05.2018 / 04:32