+ 1

Im confused how do the scanners work in java

help

1st Dec 2017, 11:27 AM
Frank
Frank - avatar
2 Respostas
+ 3
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html Look at the constructors section - a scanner can take a file, an inputstream and more. System.in is an inputstream and Scanner allows you to read that. Regarding it's next() method (and similar) notice that Scanner implements Iterator. next is a method of Iterator, and the implementation of Scanner allows you to iterate through an inputstream (or file maybe) to read the data. So system.in reads stuff from the console, and Scanner is one way of efficiently reading and handling the data
1st Dec 2017, 11:49 AM
Dan Walker
Dan Walker - avatar
0
so what is difrent from in
1st Dec 2017, 11:32 AM
Frank
Frank - avatar