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

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,858 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!