I am adding objects into a java Vector using its add(Object) method. In my example, the first 5 objects are identical, followed by 2 instances different from the first five. For some reasons, as soon as I insert the first one that is different, it changes the entire vector to that value!
'values' is an iterator containing something like '1','1','1','1','1','2','2'
Vector temp = new Vector();
while (values.hasNext()) {
temp.add(values.next());
System.out.println(temp.toString());
}
It will output something like
[1]
[1,1]
[1,1,1]
[1,1,1,1]
[1,1,1,1,1]
[2,2,2,2,2,2]
[2,2,2,2,2,2,2]
I tried using a LinkedList, as well as using add(object, index). Same thing happened.