If I have an instance of MyClass, call it myElement and add it to the two lists, or in the queue, or to the cards or something else. How many times will it be stored in memory?
MyClass myElement = new MyClass();
List<MyClass> list1 = new ArrayList<MyClass>();
PriorityQueue<MyClass> queue1 = new PriorityQueue<MyClass>();
list1.add(myElement);
queue1.add(myElement);
Will it be saved only once, and both list items indicate this location in memory? Or will I save it twice?
Croco source
share