I am using Java and have various objects that I make a list of like this:
objx o1;
objx o2;
objx o3;
objx olist [] = { o1, o2, o3 };
now I want to assign other objects to the original objects o1-o3 but using the list.
Something like:
olist[0] = onew;
But in this case only the list gets changed, not the original object o1. How can I do this in Java ?
You can’t. However you could just store the array and then you would be able to change the object referenced at each location of the array.
E.g.
Then later you could change any of the objects referenced simply by indexing the array: