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 Censoring Words - Looping Until the Value Passes

Matthew Reid
Matthew Reid
692 Points

Not getting the right error message!

So, I have been following the demonstration pretty well I think. However, I am getting stopped up by a weird error that I cannot for the life of me figure out.

String name = console.readLine("Enter a name:  ");
      String adjective = console.readLine("Enter an adjective:  ");
      String noun;
      do {
        noun = console.readLine("Enter a noun:  ");
        if (noun.equalsIgnoreCase("dork") || 
            noun.equalsIgnoreCase("jerk")) {
          console.printf("That language is not allowed. Try Again. \n\n");
        }  
       } while(noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk"));
      String adverb = console.readLine("Enter an adverb:  ");
      String verb = console.readLine("Enter a verb ending with -ing:  ");
      {
      console.printf("Tour TreeStory:\n-----------------\n");
      console.printf("%s is a %s %s.", name, adjective, noun);
      console.printf("They are always %s %s.\n", adverb, noun);
      }
    }

Please let me know if you see the error!

2 Answers

I'm not sure how picky the java compiler is about this but the opening and closing curly braces after you assign the String named 'verb' might be causing complaints from the compiler.

I tried to use your code. Is your error "reached end of file while parsing"? Usually has something to do with brackets. Make sure that every bracket that is open also is closed somewhere appropriate. I didn't get any errors after I added a closing bracket at the very end of the file.