javaif-statementinversionor-condition

Why is the inverted if-statement false?


Why does the if-statement count as false?

int money = -342;
int reviews 3;

if (!(money > 0 || reviews < 5 || reviews > 0)){}

Money is false,
the both reviews are true
and inverting them results with a true for the money,
and two falses for both of the reviews.
As I am using || for ´or´, one true should be enough to make the whole of-statement become true.


Solution

  • Because the following:

    if (!(Money > 0 || Reviews < 5 || Reviews > 0))
    

    evaluates to

    if (!(True))
    

    thus, inverted,

    if (False)