Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Kate WoodroffeCourses Plus Student 6,685 Points
I don't understand what the Scanner class is doing
There's a scanner class at the beginning of the promptForGuess method in Prompter.java. What does it do?
Emmanuel C10,636 Points
A simple text scanner which can parse primitive types and strings using regular expressions.
The Scanner class is useful for reading strings and other inputs like the console or files. Its most typically used to read input from the console, which is what System.in is. When you use scanner.nextLine() it reads everything that was entered on one line of the console and returns it as a string. In that case you can see it as the opposite of System.out.println(). where instead of writing a string to the console it reads it.
I hope that made sense, if not, feel free to leave a comment and ask questions. Good luck.