File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Static Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Data" Watch "Static Data" New topic

Static Data

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 142
Q: Where the static data saved in the memory?
David Newton

Joined: Sep 29, 2008
Posts: 12617

Like where physically?
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 1118

1. Java does not allow to use pointers so we can never know for sure the memory location of the saving of a static variable
2. static variables are common to all instances of a class, you can consider them to be "global" (with the proper priveledges)

I agree. Here's the better link:

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
Is global quite the right word for a static variable? It really means a variable which is accessible to (and can be used by) any code anywhere in your application. Global variables are popular in C.
Static fields ought to be restricted to within a class (unless they are final in which case they can be read-only global variables).

Heavy dependency on global variables is a problem in programming; it might create code where changes to global variables can cause nasty errors.
I agree. Here's the link:
subject: Static Data
It's not a secret anymore!