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

Java Basics- Your name task

I don't understand where I am going wrong on my last line

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

3 Answers

Justin Kraft
Justin Kraft
26,327 Points

Close the string with a double quote followed by a comma, then the variable name.

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

kk cheers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Michelle,

just few modifications.

Task one:

// declare a String variable and initialize (= sign) it to your name
String firstName = "Michelle";

Task two:

// use the console.printf method to write "Michelle can code in Java"
// console is a name of the Console class that has the method printf() 
console.printf("Michelle can code in Java");

Task three:

// replace Michelle with %s, this is the required String formatter
// to use the formatter place it where you want your name should be and after " " (not inside) write  ("%s some text " , firstName)
console.printf("%s can code in Java", firstName);

I hope I could help you

Grigorij

Thank you

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Michelle,

can you mark an answer as best? So other could see this post as solved.

Grigorij