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

Challenge Task 4 of 4

String firstName = console.readLine("Gordon");

String lastName = console.readLine("Sumner");

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

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

Isn't this code correct? It says Error. Help me!

7 Answers

Patrick Koch
Patrick Koch
40,496 Points

so I just tryed your solution on the first two lines

String firstName = console.readLine("Gordon");

String lastName = console.readLine("Sumner");

its true its passing, but its not right, you dont need to write the console.readLine just write

String firstName = "Gordon";
String lastName = "Sumner";

because the console.readline is conflicting with task 4

so first two tasks without console.readLine, and the lastone with

g patrick

Patrick Koch
Patrick Koch
40,496 Points

Hi Suman,

I guess they confused you a little bit, I don't know why you want to read firstName and lastName?

you just have to write:

String firstName = "Gordon";

String lastName = "Sumner";

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

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

greetings patrick

Patrick Koch
Patrick Koch
40,496 Points

I just went throw the challenge, I didnt wrote the

console.readLine

on the first 2 tasks,

The last task you just have to tell JAVA what type of variable band is, and after you passing a String. You need to declare it as "String".

g patrick

Patrick Koch
Patrick Koch
40,496 Points

your welcome, anytime again

g patrick

ps. pls vote the answer if you have time ^^

Thanks for replying. I am on the Challenge Task 4 of 4. I did the first three lines correctly but stuck on last line so please help me. It says Bummer! Make sure you capture the results from the readLine in the String band.

Didn't work. :(

Thank you so much Patrick. Now, its completed, :) Thank you again.