What is the default value of a member in an array?

后端 未结 4 1958
不知归路
不知归路 2020-12-01 23:36

I instantiate an array like this:

int array[] = new int[4];

What are the default values for those four members? Is it null, 0 or not exists

4条回答
  •  情深已故
    2020-12-01 23:50

    Integers cannot be NULL. They will have the value '0'. Even if you try to assign NULL to a int from code you will not be able to do it.

提交回复
热议问题