Dear Sir,
Why global variable is declared in heap memeory?
Thank You
Global Variable Memory Area
Hii @mohitkanodia713
The global variables in java are in heap because the class definition is stored in heap area and global variable are static in java so they can be accessed by any object or through any class and in any function.Heap is the area where things persists.
Hi Mohit, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.
Thanks, I finally understand the concept of memory allocation in java for different type of variable.