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

if (!band.equals("RESULT_1")) { fix the errors, 4-4

i searched through forums and even attempted to copy and past after all this frustration, nothing availed...

Hey there Mohamed, can you post the code you have come up with so far?

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

Yes, that code is correct. Do you still have issues?

JavaTester.java:120: error: cannot find symbol if (!band.equals("RESULT_1")) { ^ symbol: variable band location: class JavaTester 1 error

// String firstName = "Gordon";

String firstName = console.readLine("first name: %s\n");

// String lastName = "Sumner";
String lastName = console.readLine("last name: %s\n");

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

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

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

i've done everything, what's going on. it does this is my worksheet aswell.... kinda too frustrated now -.-

Hi again Mohamed, I markdown your code so it appears nicer, if you'll like to know how I did it, check out the video on the right "Tips for asking questions".

1 Answer

Hey there Mohamed. I was planning to sleep (since it is very late), but I don't want to leave you frustrated as I see you are trying really hard, so I woke up to help you. This challenge wants you to fix the errors in the commented lines, by uncommenting them line by line (uncommenting 1 line per task) and fixing the errors. Here is your code...

// String firstName = "Gordon";

String firstName = console.readLine("first name: %s\n");

// String lastName = "Sumner"; String lastName = console.readLine("last name: %s\n");

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

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

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

this code of yours doesn't work because you are doing something it does not ask you to do (create extra lines and leaving the comments as comments.)

The task gives you this...

// Sting firstName = "Gordon";

// string lastName = "Sumner";

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

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

I'll help you do the 1st one then you continue with the rest... the first one writes...

 "Sting firstName = "Gordon";"

...now, you have to clearly read the line, does it have any error ? Yes, instead of "String" it has "Sting";

okay then, since we found that error, we then go and uncomment it and fix the error and submit it. Here is the 1st task fixed.

String firstName = "Gordon";

// string lastName = "Sumner";

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

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

now you have to do the remaining 3 tasks by uncommenting a line at a time and fixing their mistakes. I hope this helps :)

ty soo much