DEV Community

Discussion on: Do you code `if (foo == true) ` in Java?

Collapse
 
florianschaetz profile image
(((Florian Schätz)))

While we do not need to fear an accidental assignment (if (foo = true) ) in java, I still prefer the short version.

If you use "helper" variables, you can always name them appropriately instead of using !, for example:

boolean isNotBuzz = obj.getFoo().getBar();
if (isNotBuzz) {
...
}