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

I am constantly getting the "Ensure you included the string formatter '%s'" error, is my syntax incorrect?

From my knowledge this is used properly but is erroring out, have I made a mistake I cannot spot?

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

2 Answers

Matthew Hardy
Matthew Hardy
4,063 Points

The method printf allows for a formatted string to be directly entered into it, you have no need for String.format. Simply typing console.printf("First name: %s",firstName); will get the job done with no problems!

Thank you so much Matthew!

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,624 Points

Hey Sean,

I'm not sure why you added String.format() to the console.printf() call. "printf" itself is used to print a formatted string. So, just delete that extra code and you're good to go.

console.printf("First name: %s",firstName);

Keep Coding! :) :dizzy:

Thank you Jason!