Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Data

 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q: Where the static data saved in the memory?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like where physically?
 
salvin francis
Bartender
Posts: 1274
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic