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

how do I do htis one.Challenge Task 3 of 4

Please help if you can

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

Can you add in what the task is instructing you to do, and what you are seeing as a problem? I remember doing this in the early stages of the Java track, but I do not recall the task and what it is telling you to do. Kind of hard to give you an answer or help if there is no direction to go with it.

String firstName = console.readLine("What is your first name:  ");
String lastName = console.readLine("What is your last name:  ");
console.printf("First name: %s",firstName);

The printf function allows you to use modifiers, like %s, to include a variable in a printed string. Specifically, the %s modifier identifies that you are placing a String variable into the string that console.printf is printing to the console, then the named variable in the second argument substitutes its value for the %s.

Hi Austen,

Rather than posting a new question for the same challenge, please reply back to your original question for further help.

You can also try searching the community for previous questions on this challenge.

2 Answers

So far, without knowing what the task is actually trying to ask you to do, the only thing that I see different in your code from what I do is that you didn't add a space between the string name and the "=", and one between the "=" and the value (console.readLine...).

Without knowing what the task is, or what result you are getting, its hard to give a good answer.

Jazz Jones
Jazz Jones
8,535 Points

You can view the challenge by clicking the green "View Challenge" button up at the top of this page

Jazz Jones
Jazz Jones
8,535 Points

Do you remember the %s placeholder?