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 trialjohn westlen
346 PointsI'm getting an error but my code is right?
String firstName="john";
console.readLine(firstName);
String lastName="User";
console.readLine(lastName);
console.printf("First name %s",firstName);
What's wrong it keeps asking if i forgot to add firstName to the printf?
[MOD: added ```java formatting -cf]
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsWhile your code is passing the first two tasks, it's a false positive. The challenge will supply it's own values for read during the .readLine()
. Your code hardwires these values which then fail in Task 3 when the check is expecting it's own value back. Fix by combining your variable declarations and the .readLine()
statements:
String firstName=console.readLine();
String lastName=console.readLine();
console.printf("First name %s",firstName);
john westlen
346 Pointsjohn westlen
346 PointsThanks for the reply, but can you simply what you said please?
john westlen
346 Pointsjohn westlen
346 Pointssorry nevermind lo thanks for the help
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsTagging Craig Dennis to review why your code would pass the first two tasks. This sets you up for failure on the third task.