When you put objects into an ArrayList, are you inserting a reference to the object, or are you making a copy of that object and inserting that object?
Here is some sample code that is not behaving as I would expect.
Here I am adding to list the immutable Integer object reference x and y.
Then I am changing x and y to reference to different objects, yet the x in the ArrayList != the Integer x. Can someone explain the gap in my expectations?
-Joey
Here is some sample code that is not behaving as I would expect.
Here I am adding to list the immutable Integer object reference x and y.
Then I am changing x and y to reference to different objects, yet the x in the ArrayList != the Integer x. Can someone explain the gap in my expectations?
-Joey