Stefan Muellerheim wrote:
why is it necessary to init the capacity, when it is not usable? where is my fault?
It is not necessary to init the capacity -- the vector will grow as needed as you add more elements. The reason that you may want to init the capacity is if you know how many elements you will be using, and you don't want the vector wasting time growing the capacity for you.
The capacity is just the amount of memory reserved for you. It is not the number of elements in the vector. And it is not possible to make an element the 5th element when there aren't four elements to put it after.
a Vector is only at a specified position settable if there is an object already.
a Vector have to set from the beginning always.
if any position, then it has to filled up with 'null'.
if any position, size() is not usable, due to the dummy-objects.
Vector should make it possible to set an(y) object to any position (without adding 'null').