This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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: 991

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)

My Website: [] Cool your mind:[] My Sally:[]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45415
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!