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 Strings, Variables, and Formatting

How can I replace < MY NAME> in the console.printf expression with the firstName variable using the string formatter?

Maybe I didn't quite understand this question. Does this mean just changing your name in the quoted text at the Variable String firstName?

please help.

From a frustrated Beginner...

2 Answers

Hi there,

Try something like this ...

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

Hope that helps.

Steve.

Thanks Steve!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Francis,

can you see the difference between challenge 2 and 3?

// I have setup a java.io.Console object for you named console

//Challenge Task 1 of 3
String firstName = "Francis";

//Challenge Task 2 of 3
console.printf(firstName + " can code in Java"); 

//change the code frome challenge 2 into code below

//Challenge Task 3 of 3 after replacing <YOUR NAME> 
console.printf("%s can code in Java ", firstName);
//replace your name with %s = String formatter and put firstName aftrer "",

I hope it helps

Let us know if you need help

Grigorij

Thanks Grigorij!