Eng.Fouad Eng.Fouad - 1 year ago 71
Java Question

!flag has two meanings in java?

boolean flag = false;
if(!flag) System.out.println(!flag); // prints true

I wonder why
being considered as
when it's a conditional parameter passed to
if statement
and as

Answer Source

It's not. if (boolean expression) { statement } means "execute the statement if boolean expression is true." Since flag = false, !flag == true. Always.