• 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

String literals and garbage collection question for Kathy & Bates

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well String literals represent objects that r placed in the string pool and r destroyed only when the JVM unloads a java application.
So my question is if we have a question on garbage collection containing string literals then can we say that the string literals r eligible for garbage collection because consider this
String s="Mohit";
s=null;
.
.
String str="Mohit";
well although the reference s is set to null the string literal can still be assigned to another reference variable until the JVM unloads the application and destroys the string pool.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mohit -
I was just talking about this...

https://coderanch.com/t/243997/java-programmer-SCJP/certification/Garbage-collection


[ December 03, 2003: Message edited by: Bert Bates ]
 
Mohit Goyal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Bert m i rite when i say that the String literals r destroyed only when the JVM unloads the application. i.e. they r always present as long as the application is running
 
You can't expect to wield supreme executive power just because
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic