If I add the same object to two different collections, does that make a copy of the object in each collection, or do the collections get references to the same object?
What I’m trying to do is use two different collections to manage the same set of objects, but allow me different methods to access and order the objects.
No, by adding an object to a collection, you are just passing the reference to that object (the address where the object is stored on the heap). So adding one object multiple times to different collections is like handing out business cards, you’re not duplicating yourself but multiple people know where to find you 😉
Here some code: