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

what is printf

strings

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "YOUR NAME";
console.printf("%s\n", firstName);

2 Answers

It is a format method...you alwas uses this with the string formater (when you use the %s) More information: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html

It is used for formated output It is used for string inheritance

printf() is a method (don't worry about what a method is right now) used to print output to the console. Without the console.printf(...) you would not see the output on your screen; it would be blank.

So someone else wrote code for printf() and you are using it to print output to your screen/console.