I used the Scanner class for the first time to solve the problems on the learning site, so I will summarize it as a memorandum.
This time, only the standard input method used in the assignment and the method of acquiring an integer are available. We plan to learn more about the Scanner class in the future.
First, you need to import the Scanner class.
The Scanner class is included in the java.util package, so if you write "import java.util. *;", All the classes in the java.util package will be imported.
Of course, "import java.util.Scanner;" is also OK.
Then pass the standard input information to an instance of the Scanner class.
Standard input can be obtained from the in field of the System class.
Here is the acquisition method when line breaks and spaces are delimiters.
To get an integer, write "nextInt".
In the case of a character string, the description method will change according to the data type to be acquired, such as writing "next".
That's all for this time.
I referred to the following article. http://www.javadrive.jp/start/scanner/index2.html http://eng-entrance.com/java-scanner-type http://todai-neet.hateblo.jp/entry/2015/09/01/131413
Recommended Posts