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!"

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

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "vishwas";
printf vishwas;

1 Answer

When calling the printf method, you need to type in the console Object before, so: console.printf You also need brackets around the thing you want to print as shown below:

String firstName = "vishwas";
console.printf(firstName + " can code in Java!");

Furthermore, we are setting firstName to be equal to "vishwas" on the first line, so there is no need to type your actualy name again. Instead you can just call the firstName variable. We then add the " can code in Java!" string to your firstName variable to print out what the question is asking.