There are no statements in java using the assignment operator. Variables contain a reference value (pointer), and when you use = , you only deal with that value.
To save the contents of myTempObject , you will need to make a copy of it.
This can be done by creating a new ArrayList using a constructor that accepts another ArrayList :
ArrayList<Object> myObject = new ArrayList<Object>(myTempObject);
Edit: As the Bohemians noted in the comments below, is this what you are asking? By doing the above, both ArrayList ( myTempObject and myObject ) will contain references to the same objects. If you really need a new list containing new copies of the objects contained in myTempObject , then you will need to make a copy of each individual object in the original ArrayList
Brian Roach Dec 09 '11 at 6:03 2011-12-09 06:03
source share