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

What's the answer for Challenge 4 of 4 for Java Basics?

The string for Which band looks like the others, but it's not correct.

6 Answers

Hi Andrew,

band hasn't been declared with a data type.

The challenge gives you the hint that it seems to be missing something at the start.

Here's the entire code I used:

String firstName = "Gordon";

String lastName = "Sumner";

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

String band = console.readLine("Which band?  ");

Can you post the entire code you have that you're trying to pass task 4 with?

Thanks Craig!

I'm enjoying the course a lot, by the way.

Hi Jason, thanks for replying...

Yeah! I thought defining it as a String was all it wanted:

String band = console.readLine("Which band? ");

Do I need another line of code?

No that should be it. Try refreshing the challenge. It's rare but sometimes they don't pass with correct code.

This is what passed for me: String band = console.readLine("Which band? ");

I don't see any difference.

I ran through it half a dozen times, and tried it in a new browser... it still didn't work. Let me know if you have other suggestions.

I sent a screenshot over to: help@teamtreehouse.com.

Thanks~

Craig Dennis
Craig Dennis
Treehouse Teacher

Hi Andrew!

I just ran through it and added the String declaration to the line in Task 4 of 4. It worked for me, I'll take a look at your screenshot, sorry for the frustration. I'll get to the bottom of it.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

I see your screenshot! You broke my mock code I use for testing ;)

You added console.readLine to the first and second lines and it didn't need it, those should just remain as the strings you had.

I will update my mock to allow for that, and sorry for the frustration.

Let me know if you have any more problems.

Took several more tries, but i finally got through it! Thanks!