Assigning a "null" to a variable (outside of its declaration) is usually
bad form. Some times, the assignment is an indication that the programmer doesn't
completely understand what is going on in the code. NOTE: This sort of assignment
may in rare cases be useful to encourage garbage collection. If that's what you're using
it for, by all means, disregard this rule :-)public class Foo {
public void bar() {
Object x = null; // This is OK.
x = new Object();
// Big, complex piece of code here.
x = null; // This is BAD.
// Big, complex piece of code here.
}
}
|