I have a variable HashMap<MyClass,ArrayList<WeakReference<MyObject>>>.
Despite the fact that weak settings are cleared of the hash map, I also want to be able to manually remove "MyObject" from the HashMap. This is the central listener object.
When I add elements to an arraylist that is associated with the main value of the hashmap key, I use .add(new WeakReference<MyObject>(owner))
When I want to remove the "I" from an external location, I send the "owner" as a parameter, which is the real object. So how can I remove this object manually from my hashmap? Can I request a new WeakReference generated from an inbound owner parameter? Will the old "new WeakReference<MyObject>(owner)"and the new "new WeakReference<MyObject>(owner)"be equal? Therefore, I can remove it from hashmap.
source
share