Not Equals Operator - Boolean
Not Started

You’re in luck, the Not Equals Operator != works the same with Booleans.

Boolean firstBoolean = true; Boolean secondBoolean = true; Boolean resultBoolean = firstBoolean != secondBoolean; // resultBoolean becomes FALSE, because they are the same Boolean thirdBoolean = true; Boolean fourthBoolean = false; //false this time Boolean resultBoolean2 = thirdBoolean != fourthBoolean; // resultBoolean2 becomes TRUE, because they are different

We can use this operator on the Boolean keywords themselves:

Boolean firstBoolean = true; Boolean resultBoolean = firstBoolean != true; // resultBoolean becomes FALSE

Oh, but there’s a twist. There’s always a twist. With Booleans, we can use the ! operator (you can call this the not operator) by itself to negate a Boolean value. By negation here, we mean reversing the truth of a statement.

! turns a true statement false, and turns a false statement true. When we use it with a variable like so:

Boolean firstBoolean = !true; // Is the same as saying: Boolean firstBoolean = false;

You can read this as “not true” - if something is “not true” it’s false. If something is “not false” it’s true:

Boolean tcvMatch = true; tcvMatch = !tcvMatch; //“not true” is false // tcvMatch is now false tcvMatch = !tcvMatch; // “not false” is true // tcvMatch is now true

Challenge

Use the new not operator to negate the value of isUserActive.