+ 1
Im confused how do the scanners work in java
help
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
0
so what is difrent from in