I am reading the book “Thinking in Java,” which says objects are stored in the heap and static variable when stored in some fixed place, say static storage, so that they can be accessed for the entire time program.
class Myclass{ static int x =0;
Although creating an object statically would not be a good idea regarding OOPS. Set it aside for a while. my questions arise that
- where the object declared as static is stored.
- how the JVM creates an instance in this case.
class Myclass { static Myclass obj = new Myclass(); //no man land }
source share