Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 676 Bytes

File metadata and controls

27 lines (20 loc) · 676 Bytes

Not

Booleans can also be "negated" using the "not" operator - !.

boolean haveOreosInHouse = true;
boolean stuckToCalorieLimit = !haveOreosInHouse;

So in this case, I have stuck to my calorie limit if there are not Oreos in the house.

haveOreosInHouse stuckToCalorieLimit
false true
true false
boolean isLoggedIn = false;
boolean isGuest = !isLoggedIn;

Now in this case, if user is not logged in he is a guest.

isLoggedIn isGuest
false true
true false