boolean flag = false;
if(!flag) System.out.println(!flag); // prints true
I wonder why !flag
being considered as false
when it's a conditional parameter passed to if statement
and as true
elsewhere?
It's not. if (boolean expression) { statement }
means "execute the statement
if boolean expression
is true." Since flag = false
, !flag == true
. Always.