I try to remove an element from vector of verctors in Java, and set this vector to the correct location.
So I try this, and of course it didn’t work because line (2) return Integer:
Definition:
Vector<Vector<Integer>> current_domain;
Vector<Integer> t = current_domain.get(k).remove(0);
current_domain.set(k, t);
For the above Vector: –
returns a
Vector<Integer>. And when you useremove(0)on it, you will get aninteger, which you cannot assign to aVector.Also when you use: –
It will modify your
vectorautomatically. So you don’t need to set it again.OUTPUT : –
So, you can see that
Vectoris modified.As a side note, I would suggest to use
ArrayListinstead ofVector.