"Clearing" the vector in this case is not exactly possible, because it is guarding integers and not references that could receive the value null
.
The most you can do is assign a neutral value (for example zero) to all elements of the vector, if this helps in your program, and keep an extra variable as counter of the last available position to write a value (or the last position where a value was written, whatever is best for your program).
To assign zero to all elements you do so:
for (int i = 0; i < x.length; i++) {
x[i] = 0;
}
You can use a for loop to assign a new value to the positions of the vectors. For example: for(int i=0;i<x.lenght; x++){ x[i] = 0 }
– Avelino