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 trialNaya Willis
2,461 PointsA task is telling me to replace my name with the firstName variable using a string formatter. I don't get it. Help plz
Help plz
// I have setup a java.io.Console object for you named console
String firstName = "Naya";
console.printf("%s can code in Java!");
2 Answers
Stone Preston
42,016 Pointsprintf statements generally look like
console.printf("%s some string %d", someVariable, someOtherVariable);
where the values of the variables passed to the function at the end are inserted into the string in place of the format specifiers.
you have one specifier, so you need a corresponding variable with it. the variable you want to print is firstName:
String firstName = "Naya";
console.printf("%s can code in Java!", firstName);
Naya Willis
2,461 PointsI just got it already, then i see the notification that someone replied to my forum question lol. Thanks though anyway