A local variable is assigned
null, and no reads of that variable occur after this assignment.
Such an assignment may have been done to help along the garbage collector, but this has been unnecessary since Java 6, where the garbage collector got a lot smarter.
Current JVMs are likely to optimize away assignments that are not used, meaning there is no net difference.
String username = ...; // ... username = null; // username is not used again.
In the example above, the final assignment to
username is not followed by any other operation.
If this assignment was only used to set a final
null value, consider removing it.