...

/

Strings and the Class Scanner

Strings and the Class Scanner

In this lesson, we will see how the class Scanner is used with strings.

We introduced the standard class Scanner in the lesson Simple Input from the Keyboard. At that time, we learned how to use it to input numbers typed at the keyboard into our program. In particular, we saw and used the Scanner methods nextInt and nextDouble. It might surprise you to learn that all input to a program, including numeric data, is read as a string. Methods such as nextInt and nextDouble convert the strings they ...