Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to destroy static variables programmatically? [closed]

Tags:

java

I want to destroy static object programmatically. Is it possible? If yes then how can i achieve this. Kindly suggest.

like image 492
Madhav Bhattarai Avatar asked Jan 13 '15 05:01

Madhav Bhattarai


1 Answers

The thing that you need to understand is - the references are static, the objects aren't. By that, I mean to say, in

static SomeClass someClassInstance = new SomeClassInstance();

the static property is on the reference someClassInstance and GC acts on instances / objects.

someClassInstance =null will make the first SomeClassInstance eligible for GC.

like image 183
TheLostMind Avatar answered Oct 04 '22 22:10

TheLostMind