Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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
Dane ParchmentTreehouse Moderator 11,023 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 DennisTreehouse Teacher
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
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