Java - Static and Dynamic Array Initialization

后端 未结 3 711
[愿得一人]
[愿得一人] 2021-01-05 20:02

Is it true that every array that is initialized during runtime is dynamic and every array that is initialized during compiling is static?

for example:



        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 20:30

    Memory is not allocated at the time of declaration.

    eg: int array[100]; ; -- won't compiles

    its only when new operator is encountered memory is allocated.

    So

    array = new int[100]; ; compiles.

提交回复
热议问题