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 Perfecting the Prototype Looping until the value passes

Looping

I don't know what's wrong with my coding in second line

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = console.readLine  ("Do you understand do while loops?") ;
response.equalsIgnoreCase ("No") ;

2 Answers

First of all, it's a good idea to declare the response string outside the loop. String response;

Secondly, it was correct that you used the response.equalsIgnoreCase("No"). What you did miss was to create the actual loop and down below you can find it.

do {
response = console.readLine ("Do you understand do while loops?"); }
while (response.equalsIgnoreCase("No"));

Hope it helps!

Bastian Petersson
Bastian Petersson
9,164 Points

It looks like you are trying to update the variable in code. However, the "console.readLine()" method asks for an input in the terminal and not in the code itself.

You are asked to store the response in a variable called "response". Firstly you have to define that variable but not initialize it. On the next line, use the "console.readLine()" method to put the user input into the new variable.

This is how i would do it:

String response;
response = console.readLine("Do you understand do while loops?");

Keep up the good work!