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

Android Build an Interactive Story App (Retired) Finishing the User Interface Formatting Strings

Still not clear about String.format.

How does format knows that %1$s needs to be replaced by mName? We did not set mName to %1$s ? Or format already has set number of symbols to recognize like %1$s ? And if it finds it, it just replaces with whatever in the brackets like mName?

Slava Fleer
Slava Fleer
6,086 Points

I think you answered to yourself =). As i understand it, format is method that can do a few things. this is one of them. http://developer.android.com/guide/topics/resources/string-resource.html

Hi Slava,

Thank you for your answer! But still does the string.format look for special characters everywhere? Because I don't see the connection between mName and %1$s. Thanks!

Slava Fleer
Slava Fleer
6,086 Points

yes. with following order.