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 trialDavid Reid
2,082 PointsStuck on "Print out to the screen using the printf method on console, "First name: " and the user's first name."
I keep getting the error that says make sure to use the first name variable, but I believe I did in the last line of code there.
// I have imported java.io.Console for you. It is a variable called console.
Print out to the screen using the printf method on console, "First name: " and the user's first name.
String firstName = console.readLine ("what is your first name");
String lastName = console.readLine ("What is your last name");
console.printf("%s\n", firstName);
3 Answers
Seth Kroger
56,413 PointsYou need to print "First name: " before the name. Also the 2nd line should be commented out with 2 forward slashes since it's not Java code.
Grigorij Schleifer
10,365 PointsTry it this way :
//here you store the user input in the String firstName
String firstName = console.readLine ("what is your first name ");
//here you use the printf method from the console class to print the users input (firstName) for the format %s
console.printf("Your first name is %s\n ", firstName);
Hope it helps :)
David Reid
2,082 PointsThanks Grigorij!
Grigorij Schleifer
10,365 PointsHey keep on descovering ... we are all beginners in some way, somewhere...
David Reid
2,082 PointsDavid Reid
2,082 PointsI finally got, it took a little bit but this helped. Thank you very much!