Back to Intellij Community

NegatedConditionalExpression

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

2025.3-rc-2280 B
Original Source

Reports conditional expressions which are negated with a prefix expression, as such constructions may be confusing.

There is a fix that propagates the outer negation to both branches.

Example:

!(i == 1 ? a : b)

After the quick-fix is applied:

i == 1 ? !a : !b