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 trialJordon Palaisy
183 PointsIssue with readLine lesson
i understand the premise of the lesson and got the coding part down but on the Task part of the lesson when on stage 3 i must have First Name in it which i do it wont let me move on. Here is what my code is like: String firstName = console.readLine("What is your First name? "); String lastName = console.readLine("What is your last name? "); console.printf("Hello, my name is %s\n", firstName);
Did i miss something?
5 Answers
ISAIAH S
1,409 PointsNo, your other lines are wrong. readLine
means that others can type stuff in after you say something. So:
String firstName = "Kai";
String firstName = "Kai"; console.readLine ("My first name is %s\n", firstName); // This isn't how you do it. Remember, this isn't printf. It's readLine.
// Try this:
String firstName = console.readLine("First Name: "); // This will say: First Name: Then you can enter your first name.
// It will set what you entered to firstName.
Hope it helps!
james Atkinson
61 Pointsi still dont get im not sure on what to type
ISAIAH S
1,409 PointsThis should work:
String firstName = console.readLine("First name: ");
String lastName = console.readLine("Last name: ");
console.printf("Hello, my name is %s", firstName);
Ken Alger
Treehouse TeacherJordon;
Welcome to Treehouse!
You are doing great, you just need to change the formatting on your output to match what is asked in the challenge directions. In this case it is asking and looking for output to match "First name: " + the value of your first name utilizing the string formatter. If you make that change to your output your code should pass fine.
Post back if you are still stuck.
Ken
Malachi Diaz
453 PointsI'm having the same problem. I thought I would get it and it makes sense to me but it's not coming up correct. My whole thing looks like:
String firstName = "Kai"; console.readLine ("My first name is %s\n", firstName); String lastName = "Diaz"; console.readLine ("My last name is %s\n", lastName); //This is the code that I think should be right but apparently isn't... console.printf ("First name: %s\n", firstName);
//The hint reads "Did you forget to pass the firstName
parameter to the printf function?" I guess I don't know how to pass the parameter on.
Malachi Diaz
453 PointsMalachi Diaz
453 PointsThanks, I realized after that I didn't actually understand the readLine haha.