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 Strings and Variables

why printf. I been learning on System.out.println("hello"); I been trying your way on my compiler and does compile

how come your system wont work with my compiler??? im using on my laptop IntelliJ

4 Answers

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,075 Points

As to answering your question regarding printf: Printf will allow you to format your string with more options than a generic system.out will. For example you can change the amount of decimals you see in variable or number printed onto a string, change the column positioning of letters, etc.

Now as to your problem with IntelliJ you may have to be more specific. What error are you receiving? Common Mistakes with Printf are generally: Using the wrong flag (ie. using %d for a double when you are supposed to use %f) Forgetting to add the tags Improper formatting (Forgetting to add the variables) Using the wrong variable for the wrong flag (Remember you must add the variables in the same order as the flags you set so if your flags are "%s %d %f you must also have the variables "string, int, double/float"

Craig Dennis, I'm still following along on the session, is well simplify to my understanding, thanks, I just started but in a different way, that's why I got a little stuck on the begging, but I'm catching on.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Cesar,

java.io.Console is intended for console applications, which we are building. Quite frankly, I did not want to confuse things too early by introducing System.out and more importantly the java.util.Scanner and System.in. I find the java.io.Console easier to grok for a brand new Java programmer, and since the environment is controlled, it is safe to use.

After compiling in your IDE, you can run it from the command line, not from IntelliJ's Run command and it will work.

NOTE: There is a printf method on System.out as well

Hope that helps!

Dane Parchment and Craig Dennis, thanks it that explains everything better, I did research it on a book I just got from java object oriented, and it mentioned there, Dane put it in a easier way of understanding, now to try on IntelliJ, thanks