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 Gwall
984 PointsHow to i make my name appear in the console?
Im trying to get my name to appear in the console for the code challenge but it is not right.
String firstName = "Sean";
console.printf("Sean");
4 Answers
William Juste
7,822 PointsThe code challenge ask for you to "Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!""
so the first line should be String firstName = "Will";
and the second console.printf("%s, can code in Java!", firstName);
good luck
Nicolas Hampton
44,638 PointsThey want you to use the variable.
Sean Gwall
984 PointsI updated my code but still not working. Code:
String firstName = "Sean"; console.printf("%s", firstName);
Nicolas Hampton
44,638 PointsDon't put the quotation mark around the variable.
console.printf("Hello my name is %s", firstName);
The program will take whatever you made firstName be and put it inside the quotation marks where you put the s. You were close, you're going the get the hang of this. :) Happy coding!
Nicolas
Sean Gwall
984 PointsStill no luck
String firstName = "Sean";
console.printf("Hello my name is %s", firstName);
Craig Dennis
Treehouse TeacherFollow the instructions carefully ;) Does that say what is being requested?
Nicolas Hampton
44,638 Pointslol, smacks head
Jason Carr
5,495 PointsHi, Sean I had the same problem but once i came to the forum i got the answer just do what WIlliam is telling you. It's not Hello my name is %s rather IT'S ("%s, can code in Java!", firstName);