Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Name.java
// 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
STAFF
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!