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 to i make my name appear in the console?

Im trying to get my name to appear in the console for the code challenge but it is not right.

Name.java
String firstName = "Sean";

console.printf("Sean");

4 Answers

William Juste
William Juste
7,822 Points

The code challenge ask for you to "Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!""

so the first line should be String firstName = "Will";

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

good luck

They want you to use the variable.

I updated my code but still not working. Code:

String firstName = "Sean"; console.printf("%s", firstName);

Don't put the quotation mark around the variable.

console.printf("Hello my name is %s", firstName);

The program will take whatever you made firstName be and put it inside the quotation marks where you put the s. You were close, you're going the get the hang of this. :) Happy coding!

Nicolas

Still no luck

String firstName = "Sean";
console.printf("Hello my name is %s", firstName);
Craig Dennis
Craig Dennis
Treehouse Teacher

Follow the instructions carefully ;) Does that say what is being requested?

lol, smacks head

Hi, Sean I had the same problem but once i came to the forum i got the answer just do what WIlliam is telling you. It's not Hello my name is %s rather IT'S ("%s, can code in Java!", firstName);