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 trialMICHAEL ADAMGBE
Courses Plus Student 9,157 PointsChallenge task 1 of 3. I cant seem to know why I cant get through this question as my code is correct
prompt a user with the question "Do you understand do while loops" and store it in a new String Variable named response.
// I have initialized a java.io.Console for you. It is in a variable named console.
console.printf("Do you understand do while loops?");
String response = console.readLine();
if(response.equals("yes")){
console.printf("yes");
}
3 Answers
Jennifer Nordell
Treehouse TeacherHi Michael! The console.readLine()
method takes one argument as a string. You can find documentation on console methods here. However, your console.readLine contains no arguments and it's causing a compiler error. My suggestion is to let the challenge give you hints on how to proceed. Try this line:
String response = console.readLine("");
The challenge will then give you another hint in the Bummer message which should get you to the next step. I hope these hints help, but let me know if you're still stuck!
Alistair Mackay
7,812 PointsYup what Jennier said, You could remove the console.printf() method and use that string in the read line section. That should be enough to get your through to the next section.
MICHAEL ADAMGBE
Courses Plus Student 9,157 Pointsthanks guys, it worked.