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!

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

Now replace <YOUR NAME> in the console.printf expression with the firstName variable using the string formatter. how?

im stuck on this part! I'm not understanding what I'm doing wrong.

String firstName = "firstName";

  console.printf("Hello, my name is %s\n", firstName);
  console.printf("firstName can code in java!\n");

2 Answers

Michael Chan
Michael Chan
15,252 Points

Hello Charon,

There are three parts to the challenge - the first part is just declaring a string with your first name, which you've got.

String firstName = "firstName";

The second part is using console to print out a string without using the variable.

console.printf("<firstName> can code in Java!");

The third is where you'll have to substitute the <firstName> portion in part two with your string variable created in part one. I'll leave this last part for you. Let me know if you need further clarifications.

Keshav Patel
Keshav Patel
494 Points

how do i do the third that is the part i don't get

? i still don't get

Now, i get it To my Juniors :), Try calling the string Variable in different statements as shown below

String firstName = "Micklo"; console.printf("Hello, my name is %s\n",firstName); console.printf("I %s am learning Java\n",firstName); console.printf("%s is talking in third person\n",firstName); console.printf("%s hopes these commands are expressed correctly\n",firstName); console.printf("%s can code in Java!",firstName);