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

Complier error referring to task number?

I have been trying to do this final part of the last section of java basics and have came across an issue that I cant seem to solve with my current knowledge.

I have closely referred to the prior video on the topic of while loops and have attempted to use that into this code example attached.

ignoring whats currently there i end up with the same error mentioning about a compiler error and it isn't even referring to any of my code/answer, (regardless of what i put in there) but the task number for the code challenge?

It is also, apparently an error on line 130 as you can see there aren't that many lines of code on this example.

JavaTester.java:123: error: ')' expected
    if (response.equalsIgnoreCase("yes"); {
                                        ^
JavaTester.java:126: error: while expected
  }
   ^
JavaTester.java:130: error: illegal start of expression
      taskNumber = 1;
                 ^
JavaTester.java:130: error: ')' expected
      taskNumber = 1;
                  ^
4 errors
Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String question = console.readLine("Do you understand do while loops?  ");
String response;
  do {

  };

1 Answer

Steven Parker
Steven Parker
231,268 Points

Task 1 asks you to "Store the result in a new String variable named response.", but this code is storing it in a string named "question" instead.

Then in task 2, the challenge asks you to "continually prompt the user in a do while loop." The code for this isn't complete yet (there's no "while" for the loop), and the prompting will need to be moved inside the loop to be done repeatedly. The variable "response" will need to be declared (but not assigned) before the loop begins; and inside the loop, it will be assigned (but not declared).