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 Receiving Input

the usage of %s

at what point do you use %s

1 Answer

When you need a placeholder for a string in a sentence. You need a placeholder when you need to replace %s with a string that changes all the time and is not static. For example when you see some log ins in a site they write someone like "Hello, [A NAME]" but that name can change so you can't put a name there by default. To make the name change based on the name of the person who logged in you have to use a place holder to a variable string that holds the name of the user. In Java when you are working with printf you can do that by using %s as a placeholder.

thank you gloria

You are welcome