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

dd

What have I done wrong? It says: JavaTester.java:155: error: while expected } ^ JavaTester.java:157: error: illegal start of expression private static void pass() { ^ JavaTester.java:157: error: ')' expected private static void pass() { ^ JavaTester.java:157: error: ';' expected private static void pass() { ^ JavaTester.java:157: error: -> expected private static void pass() { ^ JavaTester.java:157: error: not a statement private static void pass() { ^ JavaTester.java:159: error: ';' expected } ^ JavaTester.java:161: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:161: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:161: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:161: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:161: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:164: error: reached end of file while parsing } ^ 13 errors

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 while loops?");
do {
 if (response.equalIgnoreCase("no")) {
   console.printf("RAGE QUIT");
 } 
Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Please be a 'bit' more detailed when titling a question ("dd" is not at title). This causes confusion in the Community and make for a rather Disorganized and unprofessional looking environment.

Thank-You. Jason Forum Moderator

2 Answers

Did you create a test method and class by yourself ? can you download and share your workspace, or can paste in your test classes

This is a three part challenge to test your understanding of a "do...while" in Java. the first part is asking you to declare the variable. the second part is asking you to add the do while logic. the third part is asking you to print out a response after the loop is finished.

Currently, your code reflects a "do" with an "if" statement. Try to structure your logic response more like this.

do { statement(s) } while (expression);