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

Matthew Williams
Matthew Williams
3,103 Points

I'm having troubles with the second-to-last question in the 'Java Basics' course.

I believe my code is attached below. I'm trying to pass in a loop if the answer to the question is 'No' but I'm getting an error. Conditionals aren't my strength so help would be greatly appreciated. Thank you.

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?" );
do{
  if response = ("No");
} while(response);
Fahad Mutair
Fahad Mutair
10,359 Points

hey it should be like this

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

1 Answer

Matthew Williams
Matthew Williams
3,103 Points

Ah, this helped! Thank you, Fahad.