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

Naya Willis
Naya Willis
2,461 Points

printf method

this challenge asks me to use the printf method, i feel that i did it correctly, but then it says error "did you forget to pass the first name parameter" or w.e. i think I did, I'm not to sure

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

1 Answer

boog690
boog690
8,987 Points

You're initializing the firstName and lastName variables incorrectly. We want to ask the user for their first name (and store that in firstName) and last name (and store that in last name). To do firstName, we do something like:

String firstName = console.readLine("What's your first name?");

I'll let you figure out how to do last name.

Naya Willis
Naya Willis
2,461 Points

ohhh, ok I see. Thanks man