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 trialAnastasia Karpenko
2,845 PointsCannot pass through the 3rd challenge
I have a problem with the printf method. I do the same as I have done in my workspace during the video training. I checked several times, but nothing works. What am I doing wrong? Thank you
Anastasia
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("What is your name? ");
String lastName = console.readLine("What is your last name? ");
console.printf("%s", firstName);
3 Answers
Mario Blokland
19,750 Pointsmaybe it is a bit confusing because you also have to insert the variable firstName which you did, but if you read carefully the error says: Bummer! Ensure your format string contains the required text "First name:"
.
So what you only have to do is to add the string First name:
(with the colon) inside the quotation marks, before the %s
and you should be good to go.
Eric De Wildt
Courses Plus Student 13,077 PointsMario basically spelled it out so I am not giving you the answer cause he already did. But the visual side of what Mario said is this:
console.printf("First Name: %s", firstName);
Anastasia Karpenko
2,845 PointsThank you both! it worked!