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 trialSean Habel
4,407 PointsI am constantly getting the "Ensure you included the string formatter '%s'" error, is my syntax incorrect?
From my knowledge this is used properly but is erroring out, have I made a mistake I cannot spot?
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine();
String lastName = console.readLine();
console.printf(String.format("First name: %s",firstName));
2 Answers
Matthew Hardy
4,063 PointsThe method printf allows for a formatted string to be directly entered into it, you have no need for String.format. Simply typing console.printf("First name: %s",firstName); will get the job done with no problems!
Jason Anders
Treehouse Moderator 145,860 PointsHey Sean,
I'm not sure why you added String.format()
to the console.printf()
call. "printf" itself is used to print a formatted string. So, just delete that extra code and you're good to go.
console.printf("First name: %s",firstName);
Keep Coding! :)
Sean Habel
4,407 PointsThank you Jason!
Sean Habel
4,407 PointsSean Habel
4,407 PointsThank you so much Matthew!