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

Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!" Doesn;t work HELP

Console printf (firstName; "can code in Java"); i put this and it doesn't work, and i'm pretty sure this is the answer anyone can help me? i really need HELP

// I have setup a java.io.Console object for you named console
firstName = "Matteo";
Console printf (firstName; "can code in Java");

2 Answers

I tried this and it worked for me.

firstName = "Matteo";
console.printf("firstName can code in Java!");
Craig Dennis
Craig Dennis
Treehouse Teacher

Really close Amanda!

Seems like you are missing the String declaration and the replacement of the parameter.

Craig Dennis
Craig Dennis
Treehouse Teacher

Hi Matte...your missing a few things. First you need to declare firstName as a String. On your second line, the format string comes first. Remember to put a %s where you want the variable to be replaced.

Here is a similar example:

String dayOfTheWeek = "Monday";
console.printf("Today is %s", dayOfTheWeek);

Hope that helps!