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

printf

f

Name.java
String firstName = "Evanson";
System.out.println("Evanson");

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi there,

It looks like what's happening is you're trying to assign the string value twice. Once when you define the variable, and again when you're referencing it.

To print out the value of the variable once you have assign it, simply pass in the variable name to the method. Then you need to work out how to work with format specifiers like %s to display them with a formatted string. Hint... the printf method has 2 arguments separated by a comma. :-)

Jonathan is right. You can do System.out.print with your variable name and be fine. Printf would be useful for when your formatting strings. I actually learned about formatting strings("printf") going through the Java track also.