Where are static class variables stored in memory?

前端 未结 3 1657
再見小時候
再見小時候 2021-01-02 02:38

This is a follow-up question to How are static arrays stored in Java memory? .

So global variables in C/C++ are stored in the static data segment of memory. But what

3条回答
  •  悲哀的现实
    2021-01-02 03:06

    Static variables will not be stored in Heap.. They are part of Data Segment. Local variables will be stored in - Stack; Instance variables will be stored in - Heap; Class variables(Static) will be stored in - Data Segment. These variables will be shared across all objects of that class.. Your final machine equivalent java code will be stored in - Code/text segment.

提交回复
热议问题