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!

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, where's my mistake?

I can't get by this one. It says that I forgot to pass the 'firstName' parameter to the printf while it's right there.

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

2 Answers

Simon Coates
Simon Coates
28,693 Points

something like

String firstName = console.readLine("firstName  ");
String lastName = console.readLine("lastName  ");
console.printf("First name:%s", firstName);
console.printf("Last name:%s", lastName);

The first and lastnames are returned from the readLine method and assigned to variables. These variables are then used in the printf method.

ah yes what a mistake! I completely forgot that. Thank you very much