Mark Richardson wrote:If I put an object twice into an ArrayList...
As Carey implied, your question is off course to start with. In fact you don't put objects into ArrayLists. You put references to objects there. And hence Carey's answer becomes clear.
You never get to deal with objects at all in Java. When you write new Thing() what you get from that is a reference to a Thing object. If you assign that to a Thing-typed variable, then the variable contains a reference to that Thing object. You can only manipulate that Thing object via references which are contained in variables or array entries (or probably some other obscure places I can't think of right now). Nothing in your code ever contains a Thing object.
posted 4 months ago
That makes so much sense. Thank you!
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.