When you're adding the singleVector
object to multiVector
, you're not making a copy of it. So when you clear the singleVector
and change it to "b,b,b" you're also "changing" the (same) object that you added to multiVector
.
If you want to change singleVector
without modifying multiVector
you should singleVector = new Vector<>()
instead of clear()
'ing it.