If I have an ArrayList, and I added an object to it, and later I modified this object, will this change reflect in the ArrayList? or when I add the object to the ArrayList, Java creates a copy and add it to the ArrayList?
What if I change the reference to this object to null? Does that mean that the object in the ArrayList now null too?
Yes, since you added a reference to the object in the list. The reference you added will still point to the same object, (which you modified).
No, it won’t copy the object. (It will copy the reference to the object.)
No, since the content of the original reference was copied when added to the list. (Keep in mind that it is the reference that is copied, not the object.)
Demonstration: