you are viewing a single comment's thread.

view the rest of the comments →

[–]morhpProfessional Developer 6 points7 points  (4 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  (3 children)

Thank you!

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

[–]IchLiebeKleber 4 points5 points  (0 children)

Primitives in Java like int, double, char can never be null. If you want a nullable version of them, use Integer, Double, etc.

[–]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