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 Using your New Tools Fix the Errors

How to fix the fourth comment line.

what do i change?

String firstName = "Gordon";

String lastName = "Sumner";

console.printf("Hello %s\n", firstName);

Band = console.readLine("Which band?  \n");

1 Answer

To expand on what Florian said, before you assign value to any variable, you must first declare, or create it. That means putting the type that it is (String, int, List, etc.), and then the name. You can always declare a variable without assigning value, or initializing it, first, or you can initialize at declaration. Here's what that would look like:

//declare it first
String band;
//Then assign value (initialize) 
band = console.readLine("Which band?  \n");

//initialize at declaration
String band = console.readLine("Which band?  \n");

In both cases, you still have to declare (create) the variable first. Hope that all makes sense!

Florian- Whoops! You're absolutely right. Not sure how I messed that up. I'll edit mine for future readers