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

jinhwa yoo
jinhwa yoo
10,042 Points

challenge task 2 of 3 call the printf method ???/

I don't know what's wrong

Name.java
String firstName = "jinhwa";
  printf "<jinhwa> can code in java!"// I have setup a java.io.Console object for you named conso

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi jinhwa,

Craig imported Console class for you and named it "console". So to use the printf method from the Console class you need to call the name of the Class object. And it is "console" and then the function name ... printf(). Inside the parenthesis place your text.

String firstName = "jinhwa";
console.printf("%s can code in Java!", firstName);
// dont forget to call the console befor printf

The printf method expects a String formatter %s inside " " ! Where you place it, there will be your String variable (firstName). DonΒ΄t forget the comma after the second "

I hope it clears thing up :)

Grigorij