Im confused how do the scanners work in java | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Im confused how do the scanners work in java

help

1st Dec 2017, 11:27 AM
Frank
Frank - avatar
2 Antworten
+ 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