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 Receiving Input

What is the difference between using console.printf and System.out.printf? When do I use each?

What is the difference between using console.printf() and System.out.printf() ?

Thank you this clarifies things. In a production environment is one more professionally used then the other?

Stayl T
Stayl T
968 Points

I'm glad I could help. As far as I'm experienced I have seen the System.out.printf() method used most of the times. It's also easy so it is preferred.

Craig Dennis
Craig Dennis
Treehouse Teacher

In a production environment, you will probably be either using a GUI or the web and not writing console based applications.

We use java.io.Console because it does the job and didn't introduce new confusions, but even that is confusing eh ;)

Under the covers, they are exactly the same.

Hope that helps!

1 Answer

Stayl T
Stayl T
968 Points

We are using the console.printf() method because we are working with the console in the workspace. So, this method could only be used with the console. Also, to use this method you will have to create an instance of the console class and import it as well.

System.out.printf() is a static method and you can use this without creating an instance or importing anything. And this will work everywhere even if you're not working with the console!

Hope this helps!