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! While you're at it, check out some resources Treehouse students have shared here.
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 trialAdolphus Amissah
Python Web Development Techdegree Student 315 PointsUser Input
What is the difference between getting user input with the Scanner object and Console.readLine ?
2 Answers
Jordan TheBest
4,805 PointsDid some quick researched and this was some helpful information I found
BufferedReader
Since Java 1.1
Throws checked exceptions
Can read chars, char arrays, and lines
Fast
Scanner
Since Java 1.5
Doesn't throw checked exceptions
Can read lines, whitespace-delimited tokens, regex-delimited tokens, and numbers
Difficult to read single characters
Console
Since Java 1.6
Doesn't throw checked exceptions
Can read lines
Underlying reader can read chars and char arrays (stops at line bounds)
Not always available (e.g. Eclipse)
Can read passwords (i.e. read without displaying the characters)
Recommendation: Scanner
The methods for reading numbers are very useful. The exceptions are unchecked, so you do not have to write boilerplate try/catch blocks.
Aayush Mitra
24,904 PointsWell, for what I have seen they do pretty much the same thing, just with different synatx.
Short answer, but I hope that helps!
Thanks! :)
Adolphus Amissah
Python Web Development Techdegree Student 315 PointsAdolphus Amissah
Python Web Development Techdegree Student 315 PointsA lot over my head as I just started with JAVA but helps. Thanks.