Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The use of the assignment operator in controlling conditional expressions frequently indicates programmer error and can result in unexpected behavior.

Exceptionally, it is permitted to use the assignment operator in conditional expressions if the expression assignment is not the controlling expression, as shown in the following compliant example: (That is, the assignment is a sub-expression.)

Code Block
bgColor#ccccff
String line;
BufferedReader reader = // initialize
while ((line = reader.readLine()) != null) {
  // ... work with line
}

...