Possible Duplicate:
Are static fields open for garbage collection?
If an object has a static reference in some class, will that object never be garbage collected? Also at what point will a static field be initialized?
Possible Duplicate:
Are static fields open for garbage collection?
If an object has a static reference in some class, will that object never be garbage collected? Also at what point will a static field be initialized?
A static field is initialised when the class is loaded. It is available to be GCed when its class loader is unloaded.
Well, this has been asked on SO multiple times. Since these are two questions, let's break it down:
Static variables are garbage collected when the ClassLoader through which they are loaded is electable for garbage collection. Check this post: Are static fields open for garbage collection?
As for initialization, they are initialized once the class holding them is first loaded. Check this post also: Why static fields are not initialized in time?