Array Length in Java
It contains the allocated size, 10
. The unassigned indexes will contain the default value which is 0
for int
.
First of all, length
is a property, so it would be arr.length
instead of arr.length()
.
And it will return 10, the declared size. The elements that you do not declare explicitely are initialized with 0.