Input and Output
Learn how to handle user inputs in a more efficient way using the Scanner class in this lesson.
Evolution of Scanner
class
We have seen before how to take input from the users. How to use the Scanner
class is not completely new to us. However, we need to further investigate this matter for one reason.
Our goal is to create software that is interactive. In that regard, the Scanner class is the latest development that helps us write less code. Before that, we used InputStreamReader
. It reads bytes and turns them to characters. The read()
method of InputStreamReader
invokes the reading of bytes from the underlying byte-input stream.
We increase the efficiency of InputStreamReader
by wrapping the new InputStreamReader
object within a BufferedReader
object. The constructor of ...