Hi Leonard,
You mentioned a problem but you posted another code which makes hard to help. Please post
real and runnable code. And please also provide a
test case which producing not wanted results.
The suggested solution doubles the size of array for performance reasons. You don't have to create a new array, and copy all the elements on every add.
If you use this code when you increase the list by doubling its size, then you will run into trouble here. What will happen when the list size is 2 with 2 elements, and you want to add a new element? Think about it, and then you will recognize the problem.