I need to set and get a Vector in two different classes but I seem to be losing the size of the Vector in the process. If I do v.size() I get 100 for example. Then I use a setter. Then in another class I use a getter to access this Vector again. If I do v.size() in this new class I get 0. The below code is a rough example of what I have, as I can't copy paste my code exactly, since it's part of a larger private project.
public class Params {
private Vector<Integer> _v = new Vector<Integer>();
public Vector<Integer> get_v(){return _v;}
public void set_v(Vector<Integer> _v){this._v = _v;}
}
public class a {
v.add(10);
System.out.println(v.size()); //returns 1
Params p = new Params();
p.set_v(v);
}
public class b {
Params p = new Params();
v = p.get_v();
System.out.println(v.size()); //Returns 0
}