Hi,
I have a class e.g. MyDataClass.
I have a HashMap<String,MyDataClass> myMap;
For each reference in the myMap, I also have some other MyDataClass references to the same object. To be specific:
MyDataClass c = new MyDataClass();
//configure c object with appropriate values
myMap.put("akeyvalue",c);
MyDataClass ref = c;
At this point ref and myMap.get("akeyvalue") refer to the same object in memory. If I later do myMap.remove("akeyvalue") the entry in the hashmap will be removed, but the object ref will still refer to the same location. Essentially the value myMap.get("akeyvalue") still exists. How can I update it to null, so that it is synchronized to the hashmap? I.e. If I have distinct data structures/collections that refer to the same objects, what is the best pattern/design to use so as to keep them synchronized? In my small example, in the code that I do remove on myMap, I have no access to ref object. I must somehow find ref and null it. Generally, I could have a distict data structure e.g. List refs;
Thank you