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 and Variables

Call the printf function on the console object and make it print out "<YOUR NAME> can code in Java!"

Call the printf function on the console object and make it print out "<YOUR NAME> can code in Java!"

1 Answer

Devin Scheu
Devin Scheu
66,191 Points

Something like this should work:

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

Your calling the console object and using the print format method on it. The first parameter that goes in is the string that you are going to print out to the console. Since your name is a string %s is used to represent where the variable of your name will go. The second parameter is the variable that holds a string version of your name. The 'name' variable in this case is going to be the %s in the code. So if 'name' = "John" then it would say "John can code in Java!"