Hi, I have a button declared at the class level i instantiate the button in the constructor and add an actionListener object to the same. while moving to the next screen if i set the button to null would the button be eligible for garbage collection or do i explicitly need to remove the actionListener object as well? Thank You, Phani.
You don't have to remove the actionlistener, for two reasons...
ActionListeners don't (normally) have a reference to the components they are attached to
Even if the ActionListenerdid have a reference to the button, as long as there wasn't another reference to the ActionListener, they would still be garbage collected. The GC is able to figure out circular dependencies.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.