You declared your references clone1
and clone2
to refer to the same object as v
(and discarded the new Vector()
s that were just created).
Using the assignment operator =
with an object doesn't clone the object; it just makes another reference to refer to the same object.
v ----> Vector object
^
clone1 --+
You can create copies of your Vector
by saying
Vector clone1 = new Vector(v);
Visually...
v ----> Vector object
clone1 ----> Cloned Vector object