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

I am not seeing my name change from Craig, even though I am typing it as console.printf("%s is learning Java\n", first);

I am not seeing my name change from Craig, even though I am typing it as console.printf("%s is learning Java\n", firstName); it is still showing the old string using the old name even though I clear it and run javac Introductions.java java Introductions... is it an error on my end or the system? Ive closed and opened console and saved the changes but the code still says (Craig

2 Answers

Steven Parker
Steven Parker
231,184 Points

The name that will be shown is determined by the line that assigns "firstName", which is done before the line containing the "printf".

It looks like you forgot to assign the variable to the string on the line before this one.

An example of this would be something like: String firstName = "Brad";

The data type is String (the first thing listed in the code above) and the variable name you're assigning is firstName. What you follow it with, with the = afterward is the name you want it to assign to that variable surrounded by quotes.

Hope this helps! :)