Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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);
 }