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 trialPeter Kurkowski
595 PointsI have no idea how to complete this challenge
I dont understand what it's asking i'm doing exactly what its saying.
String firstName = ("Pete");
console.readLine("Pete");
String lastName= ("Kurkowski");
console.readLine("Kurkowski");
console.printf("First name:%s\n",firstName);
3 Answers
Paul Ryan
4,584 PointsIt is asking you to store the value the user inputs in the string variable.
I will give you a helping hand.
String firstName = console.readLine();
In the code above I am storing whatever input the user gives in the String variable called firstName.
The readLine method reads input from the user.
Justin Horner
Treehouse Guest TeacherHello Peter,
To set a variable to the result of a function, you'll need to declare the type of the variable, the name and assign it to the output of a method. For example, for first name you would do this.
String firstName = console.readLine();
Then print the first name like this.
console.printf("First name: %s", firstName);
I hope this helps.
Paul Willis
4,082 PointsString firstName = console.readLine("Enter first name: ");
String lastName = console.readLine("Enter last name: ");
console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);
Peter Kurkowski
595 PointsPeter Kurkowski
595 PointsThanks! Makes more sense now.