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 trialsunithatumma
639 Pointsgetting error
String firstName = "SSSS"; console.printf("firstname:%s", firstName);
I have given like this, I don't know why I am getting error @ "printf".
could you please let me know, where I am doing wrong.
Thanks,
3 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Sunitha,
Task 2 is looking for a specific output: "<YOUR NAME> can code in Java!"
The output that you currently have would be "firstname:SSSS"
It's looking for "SSSS can code in Java!"
Try changing your format string so that it matches what the challenge is expecting.
K W
3,736 Pointseye also had problems with this code challenge,***eye did figure it out but what i don't understand is the purpose of >%s< ??? why wouldn't this code work
String firstName = "stuck"; console.printf("firstName" + "can code in Java!");
any help would be appreciated
Jason Anello
Courses Plus Student 94,610 PointsHi K W,
That works too but you need to use the variable name and not a string of the variable name. You would also need a space between firstName
and can
in the output.
console.printf(firstName + " can code in Java!");
I put a space right before "can" so that name and "can" wouldn't run together.
K W
3,736 Pointsawesome thank you
sunithatumma
639 Pointssunithatumma
639 PointsHi Jason,
Thanks for quick response. I tried and got it.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsYou're welcome. Glad you figured it out!