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!

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

can u explain me what "Console console = system.console();" mean ??

i don't understand the job of Console console = system.console(); and what is system.console :/ i know that we have to don't worry about these things but if u can explaine to me pleas

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! I can try, but as you've noted this is a little outside the scope of where you are right now. But let's give it a whirl! On the right side of the equals sign we have: System.console() is calling a method named console on the System class. This returns the console that's attached to the JVM (Java Virtual Machine).

On the left of the equals sign which is much the same as any other variable declaration. It is of type Console. This is itself a class and you can find that documentation here. And the variable name is console. Now we really could have put just about any valid variable name here, but we chose console because it makes sense.

Now what you have is a type Console and to it is being assigned the current console of the JVM. The real side effect for you right now is that it acts as sort of a "shortcut". If you didn't have this, you would have to type out System.console.printf() instead of console.printf. Don't forget that good programmers are inherently lazy! :smiley:

By the way, this will all start making a bit more sense once you get to Object Oriented Programming.

Hope this helps! :sparkles:

ohh !! u gave me exactly what i want and the link of java docs is helpfull thank u so much