Back to Intellij Community

SimplifiableBooleanExpression

java/java-impl/resources/inspectionDescriptions/SimplifiableBooleanExpression.html

2025.3-rc-2454 B
Original Source

Reports boolean expressions that can be simplified.

Example:

void f(boolean foo, boolean bar) {
    boolean b = !(foo ^ bar);
  }

After the quick-fix is applied:

void f(boolean foo, boolean bar) {
    boolean b = foo == bar;
  }

Example:

void f(boolean foo, boolean bar) {
    boolean b = (foo && bar) || !foo;
  }

After the quick-fix is applied:

void f(boolean foo, boolean bar) {
    boolean b = !foo || bar;
  }