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 - Using Logical ORs

I wonder whats going on..

Ok so 

This is the code part

  String noun = console.readLine("Enter a noun:  ");
      if(noun.equalsIgnoreCase("geek") || 
         noun.equalsIgnoreCase("dork"));  {
      console.printf("That language is not allowed. Exiting. \n\n");
      System.exit(0); } 

This is the console part Whats your age? 19 Enter a name: Mike Enter an adjective: Heavy Enter a noun: Sleeper That language is not allowed. Exiting.

So apparently it blocks everything i type in, any way to correct this issue?

Your code would be easier to read if you had it formatted. Check the link below where it says "Markdown Cheatsheet" and follow instructions on how to properly format it in java. It looks like you have a semicolon directly after your if statement- remove that.

1 Answer

Jasmeet Singh
Jasmeet Singh
20,145 Points

Remove the semicolon(;) after the if case conditional check.

  String noun = console.readLine("Enter a noun:  ");
      if(noun.equalsIgnoreCase("geek") || 
         noun.equalsIgnoreCase("dork"));  <----------- it terminates the statement. The compiler won't enter the block below the statement.   
 {
   console.printf("That language is not allowed. Exiting. \n\n");
    System.exit(0);
 }