• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where the Static variables are stored?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can some body help me to answer my two Queries?
1) Where the Static variables and methods are actually stored?
2) Is a JDK can have more than one JVM.

Thanks:
Sagar
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this may belong more to Java Beginner/Intermediate than here...

About the first one, static vars are stored in fixed memory locations and prior to object creation. That's why you can use them without instantiating any objects, like with Math.PI. Remember there's one and only one static var shared among all objects, it belongs to the class, no to its instances.

About the second one, I'm not sure.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Where the Static variables and methods are actually stored?

In java, there is a class loader which loads classes into memory as objects. These objects can then be used to create instance objects like when you call new Object(). Going back to the class loader, it initializes any static fields and all methods(?) which are stored along with the class descriptor. When you go myObject.getClass(), you are seeing a view into this class object.

2) Is a JDK can have more than one JVM.
You can have multiple instances of a JVM on a pc at any time. It happens often if you see it happening or not. Not only that, you can have multiple class loaders running in a single JVM with multiple instances of the same classes. Beware though, the number of uses for multiple class loaders is low, and they are very difficult to master. If you're interested, I found http://www.onjava.com/pub/a/onjava/2003/11/12/classloader.html
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic