mardi 24 mars 2015

Destroying objects in java


Vote count:

0




If i set an object with null value dose java destroy the original reference. for example: Foo f = new Foo(); then Foo b = f if now i set b to null dose f become also null.



asked 1 min ago


2 Answers



Vote count:

0




If there are no more references to the old object then it will be garbage-collected with time.



answered 19 secs ago



Vote count:

0




No. All setting b to null does is remove the reference to the object from b. f will still have one. If you also set f to null, then the object will have no outstanding references, and will eventually be garbage collected.



answered 6 secs ago






Destroying objects in java

Aucun commentaire:

Enregistrer un commentaire