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 Using your New Tools Multiple Format Strings

I am unable to solve this an exercise

Output a sentence that takes both the name and past tense verb using a single statement. It should look like this: "name" really past tense verb this coding exercise.

I have tried one thousand times and am very frustrated.

thank you

Multiple.java
// I've imported java.io.Console for you.  It is stored in a variable called console for you.
String name = console.readLine("Enter your name:  ");
String pastTenseVerb = console.readLine("Past tense verb:  ");
console.printf("%s really %s, thisCodingExercise  ");

3 Answers

Daniel Vargas
Daniel Vargas
29,184 Points

Hi, you just have to put the variables at the end of the printf:

// I've imported java.io.Console for you.  It is stored in a variable called console for you.
String name = console.readLine("Enter your name:  ");
String pastTenseVerb = console.readLine("Past tense verb:  ");
console.printf("%s really %s, thisCodingExercise", name, pastTenseVerb);

Thank you so much Daniel. You truly saved my coding career. :)

ohhh, now I understand. Nobody explained it. %s - is there to show where the String name and other variables should be located. So instead of putting like this -> console.printf(name + "really" + pastTenseVerb + "this coding exercise"); They ask you to do it like this --> console.prinf("%s really %s, this coding exercise", name, pastTenseVerb); Although, the second way seems too complicated and you could mess it up. Hope they have explained it in the videos.