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 trialBeh Jiunn
251 PointsIO challenge Task 3 of 4
I've indicated the line console.printf("First name: %s", firstName); but it still shows errors.
// I have imported java.io.Console for you. It is a variable called console.
String lastName = console.readLine("What is your last name");
String firstName = console.readLine("What is your name");
console.printf("First name: %s", firstName);
2 Answers
Steve Hunter
57,712 PointsHi there,
This is a strange one. Your code is fine. However, the tests are complaining about the order you have your first two lines of code in. If you switch them around, so declare firstName
first, your code will pass.
String firstName = console.readLine("What is your name");
String lastName = console.readLine("What is your last name");
console.printf("First name: %s", firstName);
I don't know why this is.
Steve.
Brice Sawadogo
1,832 PointsMaybe you should try to replace this line <<console.printf("First name: %s", firstName);">> by this one <<console.printf("First name: %s , Lastname : %s", firstName,lastName);>> I am not very sure but I think that since you declared two variables, maybe the java compiler is expecting two variables.
Beh Jiunn
251 PointsBeh Jiunn
251 PointsTechnically it should work fine right? Thanks for the feedback!! :)
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsYes. It should work, as far as I am aware. I see no reason that the order of those two variables affects their use downstream of that point.