Assignment in Expression


An assigment in an expression might indicate a typing error. The programmer probably meant to compare a variable with a value. Causes for the assignment are:

The accidental assignment is already checked by Eclipse, unless a boolean is assigned.

Since 0.8.0


Bad code:

Good code:

new ArrayList(amount = 20);
amount = 20;
new ArrayList(amount);

if (name = "MyClass")
if (name == "MyClass")


Warnings generated by this codecheck can be suppressed by adding the @SuppressWarnings("assignment") annotation.

Available quick fixes

The quick fixes for this code check extract the assignment from the expression.

Since 0.8.2