HashMap data is deleted unexpectedly
I'm creating a HashMap as follows:
HiveMap = new HashMap <String, JSONArray>();
and also a private class variable to store some calculated data which will
be put into the HashMap after the calculations are done:
private JSONArray hiveList;
After hiveList is calculated, I put the hiveList into the created HashMap
(HiveMap):
HiveMap.put(hiveNode,hiveList);
When I print out HiveMap now, the output I get is as expected, with both
the fields hiveNode and hiveList existing in the Hashmap.
<"hiveNode":"hiveList">
After this is done, I assume that the data I put into the HashMap from
hiveList is going to persist, so I clear the hiveList array using
hiveList.clear();
But when I print the Hashmap after clearing hiveList, I see that the data
from hiveList is gone from the HashMap as well.
Printing the HashMap after clearing hiveList results in: <"hiveNode": >
I don't understand this behavior, I would appreciate it if someone could
shed some light on this.
No comments:
Post a Comment