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 trialUrooba Urooba
Courses Plus Student 309 Pointswhat does this line exactly does Console console=system.console();
what does system.console exactly does in this statement
1 Answer
Derek Markman
16,291 PointsSimply put, it means that you're creating a new Console object named "console".
EDIT: Sorry, I was responding to the title of this thread without actually reading what you wrote.
In the line: Console console = System.console();
On the left hand side, you're creating a new Console object and naming it "console".
On the right side you're assigning that Console object to the System class, which is a built-in java class that can be used for giving output and getting input.
From the System class you can call the inherited console() method, which "Returns the unique Console object associated with the current Java virtual machine, if any".
Also, just for a bit of further clarification. The System class is a built in java class that can be found in the java.lang package.
SOURCES: Java 8 System docs, where you can find more in depth information on the System class as well as the methods available to you from said class. https://docs.oracle.com/javase/8/docs/api/java/lang/System.html