<p>
Assignments within sub-expressions are hard to spot and therefore make the code less readable.
It is also a common mistake to write <code>=</code> when <code>==</code> was meant.
Ideally, expressions should not have side-effects.
</p>

<h2>Noncompliant Code Example</h2>

<pre>
System.out.println(i = 42);
</pre>

<h2>Compliant Solution</h2>

<pre>
System.out.println(i == 42);
</pre>

<p>or:</p>

<pre>
i = 42;
System.out.println(i);
</pre>

<h2>Exceptions</h2>
<p>Assignments enclosed in relational expressions are allowed.</p>

<pre>
BufferedReader br = new BufferedReader(/* ... */);
String line;
while ((line = br.readLine()) != null) {
  /* ... */
}
</pre>