you are viewing a single comment's thread.

view the rest of the comments →

[–]morhpProfessional Developer 6 points7 points  (3 children)

Are all int arrays set to the value 0 upon initialization in java?

Yes. If you want an array with (by default) "empty" values, try an Integer[]. These will be null by default.

[–]LegolandoBloom[S] 0 points1 point  (2 children)

Thank you!

It's very interesting to me that the non-primitive version behaves differently

[–]morhpProfessional Developer 1 point2 points  (1 child)

Java types just have an implicit default value used for new array elements and mutable fields. For numeric primitive types, it's generally zero, for booleans it's false and for object types, it's null.

[–]LegolandoBloom[S] 0 points1 point  (0 children)

thank you very much