With the following code I loose my object in the Map
after removing from the List
, but I want to keep it in the Map
:
ArrayList<object> myList= new ArrayList<>();
Map<String, ArrayList<object>> map = new HashMap<String, ArrayList<object>>();
myList.add(object);
map.put(key1,myList);
map.get(key1); // return [object]
myList.remove(get(index));
map.get(key1); // return []