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

Challenge Task 3 out of 4

I need help with the third exercise on the last stage in Java basics. I don't know what I am doing wrong. If anybody were to respond to this please help me. What am I doing wrong?

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

String lastName = console.readLine("What is your last name?");

1 Answer

The words "First Name:" need to be included in the console.printf string.

console.printf("First Name: %s", firstName);

In a string, that is characters within " ", the symbol %s is used because you don't know what the firstName variable will be, therefore it is a reference for the compiler to look for an argument after the string, in this case: firstName .

What you typed would actually work, but the challenge requires you to include "First Name: " in the output. You will find on the rare occasion that some challenges are confusing because they require very specific outputs.