For some reason newbies always assume this will work, but it doesn't. The length of
ar
is fixed when you create it (and length
is uninitialized at that time). The array will not track length
and update its length dynamically.