Does garbage collector clear it? We can't change it into null value (it is constant) and garbage collector clears up only references which are null-values. Is it possible to let garbage collector clear it? [ July 18, 2007: Message edited by: Piotr Milewski ]
When such class is cleared? An reference can't be null (then non-final (references) classes are cleared by garbage collector), so how does GC knows when to clear it? [ July 18, 2007: Message edited by: Piotr Milewski ]
There are two possiblities: reference variable is a local variable (aka, authomatic or method variable), or it is a member of a class.
In the first case:
In this case, the object referenced by variable 'a' is ellgible for garbage collection when myMethod() returns (i.e. when the reference variable goes out of scope).
In the second case:
In this case the object referenced by class' instance variable 'a' is ellegible for garbage collection when the object it belongs to (e.g. the object referenced by obj) becomes ellegible for garbage collection.
I hope it is clear now. [ July 18, 2007: Message edited by: Sergio Tridente ]