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

Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user

pls help me!!

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("First name:");
String lastName = console.readLine("last name");
console.printf(firstName);

1 Answer

Yanuar Prakoso
Yanuar Prakoso
15,196 Points

Hi there...

You almost made it through. You just need to revise your code a little to print "First name: (your name here).

Here is how the revision looks like :

// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("First name:");
String lastName = console.readLine("last name");
//console.printf(firstName);<--here is your problem lies. You need to modify it into:
console.printf("First name: %s/n", first name); //<--this is the right way to do it

The last task of the challenge if I am not mistaken is similar with console.printf revision. You should be able to do it using that revision as example. I hope this can help. Good luck and happy coding.