Possible Duplicate:
What is the preferred way to write boolean expressions in Java
Today, me and my colleague raked up an argument.
Which is a better way to use the boolean variables in Java code along with if statements.
boolean foo=true
//1.
if(foo == false)
// do something
else
// do something else
//2.
if(!foo)
// do something
else
// do something else
I support [1], since I think it’s more readable.
What do you guys think?.
Number 2, along with “foo” having a descriptive name, so that the code reads well:
if (!hasPurple)
...