Back to Intellij Community

UnaryPlus

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

2025.3-rc-2731 B
Original Source

Reports usages of the + unary operator. The unary plus is usually a null operation, and its presence might represent a coding error. For example, in a combination with the increment operator (like in +++) or with the equal operator (like in =+).

Example:

void unaryPlus(int i) {
    int x = + +i;
  }

The following quick fixes are suggested:

  • Remove + operators before the i variable:

  • Replace + operators with the prefix increment operator:

Use the checkbox below to report unary pluses that are used together with a binary or another unary expression. It means the inspection will not report situations when a unary plus expression is used in array initializer expressions or as a method argument.