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

printf() I am being told that this is not the usually and common thing used in Java is that correct?

I was told that using printf() is frowned upon by a guy I know in school for hava, So I am curious is that true? why printf() and not System.out.println() ?

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Ronald!

I haven't heard of printf being frowned upon, and a quick Google didn't turn up any heated debates. It's quite common to use for formatting text out to the screen. Java Basics builds up to a program in which it is used. There is such a thing as String concatenation where you combine Strings using the + but I find that leading with this often creates some actual bad practices in terms of String management, which is a little different in Java.

The reason why I start out using java.io.Console is because we are writing a console application. Some beginning courses jump right into using System.out, but as I think you can start to tell I don't like to introduce stuff until we really need it. This is in an effort to not put too much information in front of you. I think that console is a very nice light intro into input and output. One reason I believe it is not used in other beginner classes that are using an IDE based learning approach is because it is hard to override in the IDE as it is final, we have the luxury to avoid that as we are using Workspaces. Another possible reason is because it was introduced in Java SE 7, so some still have not upgraded their course content.

We will go over System.out.println in the second course in the Learn Java track which is called Java Objects and I will explain what it means. In this course it just wasn't what we were focussing on, and seemed like cognitive overload.

Eventually you'll move away from the console, and will be using loggers which use string formatting, much like printf. On the webside of things, you'll be using a templating language which also encourages you to think heavily about placeholders.

Does that help?

Do you have any idea when the second course will be available? because if I can get all my java here I would rather that as I LOVE the way you teach here.

Craig Dennis
Craig Dennis
Treehouse Teacher

Hi Ronald,

There are 4 courses currently in the Learn Java track all ready for your consumption ;)

Thanks for the feedback!

Ahh ok cuz you said you ntroduce it in course 2 so i thought course 2 was not out yet lol