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

Java Java Basics Getting Started with Java Introduction to Your Tools

Quinton Rivera
Quinton Rivera
5,177 Points

Console console = System.console, what does this mean

I think it means we create a console object named console but this part: System.console totally loses me I am review this course and realized I dont know what this part means

1 Answer

Shelman, good question. Most of us just use it. But there should be an answer to your question. Here's what I found in the Java documentation under Console:


public final class Console extends Object implements Flushable

Methods to access the character-based console device, if any, associated with the current Java virtual machine. Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console.

If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking the System.console() method. If no console device is available then an invocation of that method will return null.

In short, you need this to use TH's console in the workspace.

Re you first comment, the line of code is creating a Console object named console. A small change, but an important one. Classes in Java are always capitalized.