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 trialRonnie Barua
17,665 Pointsprintf function making me feel like an idiot? can someone please tell me why it doesn't work. Thanks in advance
firstName = "Ronnie"; console.printf("Ronnie");
5 Answers
Jason Anello
Courses Plus Student 94,610 PointsSorry Ronnie, I went and looked at the challenge and realized there was more to it.
Part of the problem is that you're not printing your variable but also this challenge is looking for a very specific output.
"<YOUR NAME> can code in Java!"
Ultimately, your output needs to be "Ronnie can code in Java!"
You can use a format string in printf or string concatenation if that's been taught.
Let us know if you still can't figure it out.
Ronnie Barua
17,665 PointsThanks Craig! I did try with quote probably that's why it didn't work.
Ronnie
Ronnie Barua
17,665 PointsSorry! Your trick has failed this time. What else should I try?
Jason Anello
Courses Plus Student 94,610 PointsDid you use Luke's code as is or make the corrections that Craig Dennis mentioned.?
Eric De Wildt
Courses Plus Student 13,077 PointsYour passing in a hard coded string "Ronnie". But you have already declared "Ronnie" in a String variable named firstName. All you have to do is pass in the variable.
No offense but Luke's code is full of syntax errors.
Luke's code should look like this
String firstName = "Luke";
console.printf(firstName);
Notice the differences in syntax.
Edit: Task clarification
My comment pertains to task 3 for task two Jason Annello is correct.
Jason Anello
Courses Plus Student 94,610 PointsHi Eric,
Task 2 wants you to use the hard-coded name but with a specific string for output.
Task 3 then has you use the variable in a format string.
Luke Glazebrook
13,564 PointsHi Ronnie!
If you are trying to print out what is stored in the variable you can do so as follows.
String firstName = "Luke";
console.printf(firstName);
I don't know if this is what you are looking for! If it isn't reply back and I shall help you further.
-Luke
Craig Dennis
Treehouse TeacherPsst...don't forget the semi-colons and the case of console matters.
Ronnie Barua
17,665 PointsHi Luke, You are not correct. Unless Treehouse server is falling apart.
Luke Glazebrook
13,564 PointsThanks for the reminder Craig! Python has taken the semi-colon out of me!
Also Craig, just out of curiosity... why are you using console.printf on your course instead of System.out.println?
Craig Dennis
Treehouse TeacherIt'll do that ;) Swift is helping that cause too.
Luke Glazebrook
13,564 PointsSwift may also be a contributing factor! In fact now when I go back to Java it feels foreign to add semi-colons at the end of every line.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsSorry, I jumped the gun.
My instructions on using a format string pertain to task 3.
All you really need to do for task 2 is print the output string with your name hard-coded in it.
In task 3 you'll use the variable.
I hope that clears it up for you.
Ronnie Barua
17,665 PointsRonnie Barua
17,665 PointsThanks Jason! I missed that. You are very careful I can see. I'll try that.
Ronnie Barua
17,665 PointsRonnie Barua
17,665 PointsThanks Jason! I did work.
Ronnie