int array initialization

前端 未结 7 2115
暗喜
暗喜 2020-12-04 20:15

I have here a simple question related to Java. Let\'s say you have an int array as instance variable:

int[] in = new int[5];

So, now by def

相关标签:
7条回答
  • 2020-12-04 20:44

    For primitive type arrays it is initialized to their default values. In the documentation it says :

    a single-dimensional array is created of the specified length, and each component of the array is initialized to its default value

    For the integer type default value is 0.

    0 讨论(0)
提交回复
热议问题