I have a class which has static members also non-static members like :
public class StaticClassObjectCreations {
public static void doSomeThing() {
// TODO implementations static
}
public void nonStaticMethod() {
// TODO implementations for non static
}
public static void main(String[] args) {
StaticClassObjectCreations obj = new StaticClassObjectCreations();
StaticClassObjectCreations obj1 = new StaticClassObjectCreations();
}
}
as we can see the number of object creation is not restricted and the non-static methods can be accessed with the help of objects created with new keyword.
the static methods or member variables will be also available for each instance and they can be accessed with out creating objects also.
now my question is : How the JVM maintains the instances for static block of code or in other words what happens to these static blocks when creating objects with new keyword.
thanks.