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?

Jeremy Hill
Jeremy Hill
24,306 Points

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