Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java IO

What did I do wrong

What did I do wrong

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("Ryan");
console.printf =("%s",firstName);

Make sure to read the directions carefully.

It asks to display "First name: " followed by the first name entered, so the output would like like this:

First name: firstName

1 Answer

Tsenko Aleksiev
Tsenko Aleksiev
3,818 Points

The idea here ( without telling you exactly what to do ) is: console asks "What is your name? " - you type in your name and what you have typed is saved in the variable firstName console asks ( I assume ) "What is your last name? " - you type in your last name and the same is saved in the second variable lastName. Than, using formatted print ( printf() ) you are telling Java to place in this placeholder "%s" ( s means String ), the variable you give to it, in your case firstName. Without seeing the condition, I believe it would be something like printf("%s %s", firstName, lastName). Think about it :)