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

Siddhant Dahiya
Siddhant Dahiya
156 Points

Now replace your name with the firstname variable using the string formatter

console.printf("my name is %s/n, firstName"); String firstName = ("sid"); console.printf("%s can code in Java/n, firstName");

its not working what wrong with this?

1 Answer

Dan Johnson
Dan Johnson
40,532 Points

Since you have quotes around the comma and firstName variable, it's treating the entire thing as one string. printf is expecting the first argument to be the string you want to format, and the following argument(s) to be the values to fill the placeholders with. So you'll want to write it like this:

String firstName = "YourName";

console.printf("%s can code in Java!", firstName);