This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic