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 trial
Dylan Pham
915 PointsWhat is the purpose of "import java.io.Console"? What does setting up a Console object allow me to do?
is there a difference between "console.printf" and "System.out.println"?
1 Answer
andren
28,558 PointsThe printf method found on the console object and the System.out object are identical, the same is true for the print and println methods. But the console object contains methods related to getting input from a user like readLine which is not found on System.out, and that is used pretty heavily in some of Treehouse's courses.
There are alternatives to using the console object for getting input from a user but they also require you to create an instance of an object, and they are arguably a bit more complex to use and lack some features that readLine has.
One disadvantage of console though is that it is an object that (for various complex reasons) does not work when you run your code through most Java IDEs like IntelliJ IDEA, Eclise, etc. So if you are using an IDE you pretty much have to use alternative solutions like System.out for output and the Scanner class for input.