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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Grigorij Schleifer](https://uploads.teamtreehouse.com/production/profile-photos/3207582/micro_wallhaven-15652.jpg)
Grigorij Schleifer
10,365 PointsConsole question !
Hi folks,
why do we code
Console console = System.console();
//and not
Console console = new Console();
Thx
Grigorij
4 Answers
![Craig Dennis](https://secure.gravatar.com/avatar/950c867932cc1483d8aa3dad92c4cb81?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Craig Dennis
Treehouse TeacherHey Grigorij!
System
is a class and it has a static
public
field called out. System.out.
That console
method
is also static
.
Remember the static
keyword let's you use the class without creating an instance.
Hope that helps!
Christopher Augg
21,223 PointsLets look at the documentation to answer this question:
According to its documentation, "The System Class contains several useful class fields and methods. It cannot be instantiated."
It provides a console method that "... returns the system console, if any, otherwise it returns null." It is a static method.
The Console Class is not meant to be instantiated either. The Singleton Design Pattern is followed for its implementation to ensure that only one instance of the Console class is ever created. It states within the documentation, "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."
I hope this helps.
Regards,
Chris
![Grigorij Schleifer](https://uploads.teamtreehouse.com/production/profile-photos/3207582/micro_wallhaven-15652.jpg)
Grigorij Schleifer
10,365 PointsSo you take the System class and use the dot (.) operator to access the methods inside the System class. But what is this magic Systen class used for???
Why do we call:
Syste.out.println ...
Does the System class has the out() method????
Grigorij
![Grigorij Schleifer](https://uploads.teamtreehouse.com/production/profile-photos/3207582/micro_wallhaven-15652.jpg)
Grigorij Schleifer
10,365 PointsHi Craig,
thanks !!!!
Now I understand :)