- 1
Why is hasNext() method in java returns true without even adding anything in stdin?
I was working on a program in java to known the EOF of the input file When doing this the following code is a bit confusing Scanner in=new Scanner(System.in); System.out.println(in.hasNext()); This code outputs "true" even without taking any input?
3 Antworten
+ 2
Are you sure? Am getting false only.. Check it again once..
+ 1
Thank you Martin Taylor,
My test case input is a file input in hackerrank I am getting the answer required but i am a little confused on how i got it.
Now I came to know that giving input to Scanner class System.in takes all inputs and we assign variables in required manner .