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

Selvio Perez
Selvio Perez
5,694 Points

This is not suppost to print out the user's first name?

Print out to the screen using the printf method on console, "First name: " and the user's first name. (this is the challenge)

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine( "Tell me your first name      ");
console.printf("Hello %s\n", firstName);
console.printf("$s you are doing it great man\n",firstName);
String lastName = console.readLine( "Tell me your last name      ");
console.printf("Hello %s\n", lastName);
console.printf("%s you are doing it great man\n",lastName);

String firstName = "Guy";
console.printf("Hello %s\n", firstName);

2 Answers

Hi Selvio,

When it comes to challenges, try to stick to what it asks you to do. This should be all the code you have:

// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("What is your first name? ");
String lastName = console.readLine("What is your last name? ");
console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);
Selvio Perez
Selvio Perez
5,694 Points

Thank you so much marcus

You're welcome, and don't get me wrong, I like that you're adding extra lines to make it more personal, but challenges are generally very specific about what they want. Cheers Selvio! Happy Coding!