This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static and gc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static and gc" Watch "Static and gc" New topic

Static and gc

Marcela Blei
Ranch Hand

Joined: Jun 28, 2000
Posts: 477
If you set a static variable to a value but you don�t instantiate an object for that class: What�s the lifetime for your set value?
Eg: Putting the following sentence in my main method

What�s ensure me that when I instance a Calendar object in any object of my application, my default Locale will be the one I�ve set.

[This message has been edited by Marcela Blei (edited June 30, 2000).]
Adrian Ferreira
Ranch Hand

Joined: May 29, 2000
Posts: 118

From API about setDefault method:
"Sets the default locale for this instance of the Java Virtual Machine."
So, as Locale.FRENCH, creates an instance of Locale class, this object can not be collected by GC until the end of the program.
Now about static an GC:
Static class or value can not be collected by GC. They are defined at compile time and are attached to class code. GC exists to free memory alocated during execution time for class instances (objects).
Hope it helps!
jQuery in Action, 2nd edition
subject: Static and gc
Similar Threads
Pass By Reference
Javabeat mock 2, question 14
Design for Collection, or its methods?
serialize a static variable?
plz explain the output......