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

Java Basics

Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user has entered. I get stuck here, please help!

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey there,

You're getting there. First you have declared the last name variable twice, so just delete one of them.

Second, your printf line, which is looking for a Formatted string is hard coded with a literal string. Have a quick look back at this video starting at about the 5:00 mark. Craig explains string formatting and how in put in the variables instead of hard coding the values.

Have that quick review and then give it another shot. If you're still stuck, leave a comment here. :)

Keep Coding! :dizzy:

Thanks Jason for your help! I just got the "Getting started with Java badge". I am feeling motivated☺! Thanks again!