This question already has an answer here:
- Fields of class, are they stored in the stack or heap? 3 answers
The earlier post dealt with the value and reference types and their memory allocation.
Here I'm trying to understand the memory allocation of static members.
I have a simple class which has got both static and non-static integers like one shown below.
class Sample
{
public int nonStaticInt = 0;
public static int staticInt = 0;
}
My question here is, where do static integer reside? Stack/ a Heap. And how do they get into memory first even before any object creation.
Thanks!