This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Static variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static variable" Watch "Static variable" New topic

Static variable

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Dear all,
When are static variables eligible to garbage collection?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Static variables are garbage collected when the class they belong to is garbage collected. Classes can only be collected when nothing refers to that class anymore.
kind regards
John Wetherbie

Joined: Apr 05, 2000
Posts: 1441
If the static variable is being used by a number of objects then it is eligible for GC when the last object using it is GC'd.

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
I agree. Here's the link:
subject: Static variable
Similar Threads
Single tone Vs Static
WA #1.....word association
static and non static methods
property file dynamic vs static
static and non static methods