Return value of assignment operation in Java

The assignment operator in Java returns the assigned value (like it does, e.g., in c). So here, readLine() will be executed, and it's return value stored in line. That value is then checked against null, and if it is null, the loop will terminate.


(line = reader.readLine()) != null

means

  1. the method readLine() is invoked.
  2. the result is assigned to variable line,
  3. the new value of line will be proof against null

maybe many operations at once...


Assignment expressions are evaluated to their assignment value.

(test = read.readLine())

>>

(test = <<return value>>)

>>

<<return value>>