In Java “not” is a bit awkward when used with a String method like “equals”

  • if (name.equals(“steve”) {    } is easy to understand. If the name equals “steve” then execute the code block that follows.

What about if the name does not equal steve?

  • if ( ! name.equals(“steve”)  {  } is a bit awkward but essentially the code block will execute if the name does not equal “steve”. The exclamation mark before the statement means “is not equal”

Here is the NOT exercise with the if statement and boolean operators to make it a bit more challenging

Click here for the NOT exercise

Here is the memo

Click here