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

Thatcher S.
Thatcher S.
383 Points

compile error "illegal start of type"

Here is the chunk of code with the error in it:

String name = console.readLine("Enter a name:  ");
      String adjective = console.readLine("Enter an adjective:  ");
      String noun;
      boolean IsInvalidWord;
      do {
        noun = console.readLine("Enter a noun:  ");
        isInvalidWord = (noun.equalsIgnoreCase("dork") ||
                                 noun.equalsIgnoreCase("idiot"));
        if (isInvalidWord) {
          console.printf("That is mean. Try again.\n");
        }
      } while(isInvalidWord);
      String adverb = console.readLine("Enter an adverb:  ");
      String verb = console.readLine("Enter a verb ending with -ing:  ");
      console.printf("Your TreeStory:\n---------------\n");
      console.printf("%s is a %s %s.  ", name, adjective, noun);
      console.printf("He/She are always %s %s.  \n", adverb, verb);

I am getting the error with the While statement.

1 Answer

When declaring this variable, you're using a capital 'I'

boolean IsInvalidWord

But when using it in your code, you're using a lower case 'i' ! :)

while(isInvalidWord);
Thatcher S.
Thatcher S.
383 Points

Thanks! That fixed it.