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

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

Java Basics > Task 3 of 3

3 Answers

A Y
A Y
1,761 Points

Eren,

Instead of having your first name typed directly "hard coded" in the printf method like that: console.printf ("Hello, my name is Amir");

Declare your first name as a string and use the string formatter in printf to print it like that: String firstName = "Amir"; console.printf ("First name: %s", firstName);

Hope this will help you, Amir

A Y
A Y
1,761 Points

Erene,

You probably know how print your name to the screen you use printf method such as: console.printf ("Hello, my name is Erene"); Anything between " " is text or String and will be print on the screen the way you have typed it.

In your question: Now replace <YOUR NAME> in the console.printf expression with the firstName variable using the string formatter. <YOUR NAME> is your actual name "Erene". firstName variable means using a variable to keep the value of your name "Erene" on it: String firstName = "Erene"; The string formatter is the %s which formats value as a string. It will format the firstName variable to String "Erene": console.printf ("Hello, my name is %s", firstName);

All what you have to do here is to simple steps: String firstName = "Erene"; console.printf ("Hello, my name is %s", firstName);

I believe this tutorial website will help you to understand more about Java basics: https://www.javatpoint.com/java-tutorial

Hope that I was able to give you any help, Amir

I'm still quite confused...

:(