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

how can i construct that sentese using the shown format below *name* really*pastTenseVerb??

help me please!

Multiple.java
// I've imported java.io.Console for you.  It is stored in a variable called console for you.
String name = console.readLine("what is you name");
String pastTenseVerb = console.readLine( "she went to school yesterday");
console.printf("Amina really went  school yesterday %s");

1 Answer

Binyamin Friedman
Binyamin Friedman
14,615 Points

To format variables into a string, insert as many placeholders into the string as you want (%s for strings) wherever you want. Put the variables to replace the placeholders afterwards as arguments of the method.

String variable = console.readLine("Show me how to "); console.printf("Here you go! Make sure that you can do %s without copy and pasting!", variable);

Binyamin Friedman
Binyamin Friedman
14,615 Points

I don't want to be negative, but you've asked 3 other questions that are almost identical to this one. Make sure to watch the video at a pace that works for you. You can slow down the video if that helps.