I encountered a statement in java
while ((line = reader.readLine()) != null) {
out.append(line);
}
How assignment operations return value in Java? As the statement we are checking is line=reader.readLine() and comparing it with null. Because readLine will return string , how exactly we are checking for null?
解决方案
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.