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 trialPam Russell
675 PointsHow to store a users last name using console.readline
I am trying to do question 2 of the challenge and cannot find out how to store a users last name using console.readline. I got the first name right but not the second. Watched the video again and cannot figure it out.
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("What is your name? ");
String firstName = console.readline("What is your name? ");
3 Answers
Tod Novak
3,173 PointsAlso, I think the console.readline is case sensitive. It should be console.readLine(""); With a capital "L"
Mario Blokland
19,750 PointsHi Pam Russell,
without looking at the exercise and see what exactly is expected for you to do, I can see that you overwrite the firstName
variable in the second line. Try to change the second variable name to lastName
.
Did this fix your problem already?
Santiago Martinez
5,764 PointsI agree with Mario, just rename the second variable. You have two firstName so when you are storing the first input it will store what you type but than you will have to type again and it will store it in firstName which will override it
String firstName = console.readLine("What is your first name? "); String lastName = console.readline("What is your last name? ");