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 trial

Java Java Basics Getting Started with Java IO

I'm new to this can someone help me understand what I'm doing wrong.

Using the console's printf method, display a message that says, "Last name: " followed by the last name that the user has entered.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("Nygle");
String lastName = console.readLine("Gillett");
console.printf("Hello, My Name Is %s\n", firstName);
console.printf("%s is learning how to wrte java\n", firstName);
console.printf("First name");
console.printf("Last name %s", lastName);

3 Answers

Steven Parker
Steven Parker
229,783 Points

The instructions say to print "Last name: " (with a colon) but you don't have a colon.

But more than that, you have a lot of extra print statements that were not asked for by the challenge, and you'e missing the one that task 3 asked for. Did you have one before and remove or change it?

And the readLline function doesn't take an argument (but I guess the challenge didn't catch that).

The third question said. Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user has entered.

I added the colon to the line but I'm still getting it incorrect saying. Did you forget to pass the lastName parameter to the printf function?

Steven Parker
Steven Parker
229,783 Points

Task 3 is about the first name. And it wants you to show "First name: ", but you have "Hello, My Name Is " instead.
Task 4 is about the last name, and it wants to see "Last name: " (with a colon).

You will need to fix both of these, and remove the other lines that the challenge did not ask for.

Sławomir Lasik
Sławomir Lasik
7,792 Points

In the challanges write the minimum that is required. Couse when You write more the grading system prints out difficult to understand answers.

But to the point.

This is what your program runs:

Nygletest1
Gilletttest2
Hello, My Name Is test1
test1 is learning how to wrte java
First nameLast name test2

I wrote in cosole test1 after Nygle and test2 after Gillet.

I think You can see the problem by yourself now. If not. Go through videos one more time, couse I think you might do not understand it correctly.

thank you that did help me understand the problem I also saw the extra lines I had in there I appreciate your help