I've got a hashmap who contains a arraylist as value. I want to check if one of the arraylists contains a object, and then remove that object from the arraylist. But, how?
I've tried using some for loops, but I get a ConcurrentModificationException then, and I can't get that exception away.
My hashmap:
HashMap<String,ArrayList<UUID>> inareamap = new HashMap<String, ArrayList<UUID>>();
I want to check if the ArrayList contains the UUID I've got, and if so, I want to remove it from that ArrayList. But I don't know the String at that position of the code.
What I already tried:
for (ArrayList<UUID> uuidlist : inareamap.values()) {
for (UUID uuid : uuidlist) {
if (uuid.equals(e.getPlayer().getUniqueId())) {
for (String row : inareamap.keySet()) {
if (inareamap.get(row).equals(uuidlist)) {
inareamap.get(row).remove(uuid);
}
}
}
}
}