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 trialJohan Delgado
5,484 PointsChallenge Task 3 of 3
I got stuck after task 2
// I have setup a java.io.Console object for you named console
String firstName = "Ben";
console.printf("%s can code in Java!, firstName");
4 Answers
Edith England
4,270 PointsHi Johan
Just took a look at Challenge 3.
Your problem is that in the second line you've put firstName in the quotation marks. The variable needs to go outside the quotation marks.
The following code should work:
console.printf("%s can code in Java!", firstName);
hth
Edith
Allan Clark
10,810 PointsYou have the end quote " too far back. It sends the name of the variable to printf as part of the String instead of as an argument. Try putting it before the comma.
Johan Delgado
5,484 Pointsactually it worked it is not task 2 the problem, the problem is: task 3: Challenge Task 3 of 3
Now replace in the console.printf expression with the firstName variable using the string formatter.
I couldn t go any further than that...I'm stuck
Allan Clark
10,810 PointsYes and these instructions are for the solution for task 3 of 3: Move your end quote to inside the comma.
Edith England
4,270 PointsHi Johan.
Yeah I remember being confused by what was required on this one.
I think the Part 2 answer you were given above is actually the Part 3 answer, but it will pass part 2 (I've checked).
Part 2 is asking you to write something like
console.printf("Edith can code in java!");
Part 3 is asking you to change it to include the variable, so
console.printf(%s can code in java!", firstName);
But I've checked and if you use the code suggested in the answers above it should pass part 2 AND part 3.
hth
Edith
Johan Delgado
5,484 Pointsplop!! ok thank you guys. I smelled something was repetitious on this. You really rock it, I like this place better now since I can count on you guys. Thank you so much.
Johan Delgado
5,484 PointsJohan Delgado
5,484 Pointsactually it worked it is not task 2 the problem, the problem is: task 3: Challenge Task 3 of 3
Now replace <YOUR NAME> in the console.printf expression with the firstName variable using the string formatter.
I couldn t go any further than that...I'm stuck