Unary plus
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:
The following quick fixes are suggested:
Remove
+
operators before thei
variable:void unaryPlus(int i) { int x = i; }Replace
+
operators with the prefix increment operator:void unaryPlus(int i) { int x = ++i; }
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.
Inspection options
Option | Type | Default |
---|---|---|
Only report in confusing binary or unary expression context | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |