How are static arrays stored in Java memory?

前端 未结 7 1935
名媛妹妹
名媛妹妹 2021-02-18 21:33

So in a language like C, memory is separated into 5 different parts: OS Kernel, text segment, static memory, dynamic memory, and the stack. Something like this:

7条回答
  •  一向
    一向 (楼主)
    2021-02-18 21:55

    The value of a is just a reference to an object. The array creation expression (new int[2]) creates a new object of the right size, and assigns a reference to a.

    Note that static in Java is fairly separate to static in C. In Java it just means "related to the type rather than to any particular instance of the type".

提交回复
热议问题