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 trialMohammed Qedan
582 PointsPrintf ("My name is %s", firstName);
I keep getting compile error
// I have setup a java.io.Console object for you named console
String firstName="MOHAMMED";
Printf ("My name is %S", firstName);
2 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Mohamed,
Try something like...
console.printf("your message %s", firstName)"
There a couple of syntax errors making the compiler throw some errrors :-)
andren
28,558 PointsThe printf
method belongs to the console object, so you have to call it using console.printf()
not simply printf()
. Also capitalization differences matter. Printf
and printf
are considered to be entirely different words as far as Java is concerned, so you have to make sure to type it with the proper case.
You also have to use the exact string the task instructs you to use. The task asks you to print out <YOUR NAME> can code in Java!
not My name is <YOUR NAME>
. So you have to change the string you are printing out to match that sentence.
andren
28,558 Pointsandren
28,558 PointsIronically enough your example contains a syntax error as well .