• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

eligible for garbage collection

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i can't understand any can explain this concepts?
Regards
Rex
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rex,
Here first at the time of creation
a refers to Integer object i.e a-> Integer Object
b refers to Long object i.e b-> Long Object
c refers to String object i.e a-> Sting Object

We will go now line by line-:

Line 4-: a-> null, so Integer Object is not being referenced by any references.

Line 5-: a refers to what c is refering
i.e a->String Object , c->String Object , b-> Long Object

Line 6-: c refers what b is refering so-:
c-> Long Object, b-> Long Object ,a-> still String Object

Line 7-: b refers to what a is refering so finally we land at
a-> String Object, b-> String Object and c-> Long Object

So only our Interger object has lost references to it. So eligible to GC.
I hope this clears it...
 
reply
    Bookmark Topic Watch Topic
  • New Topic