Question: Suppose we have the below code:

```
public class HashMapTest {
    public static void main(String[] args) {
        HashMap<String, ArrayList<String>> map1 = new HashMap<>();
        ArrayList<String> al = new ArrayList<>();
        al.add("A");
        al.add("B");
        al.add("C");
        map1.put("1", al);
    }
}

```

At first the `HashMap` would be looking like:

```
{{"1"},{"A","B","C"}}

```

Now I want to find the value `"B"` in `HashMap` and want to delete this value from `arraylist` which is present in `hashmap`.

So that the final result would be looking like:

```
{{"1"},{"A","C"}}

```

Can anyone please tell me how to do this?

Answer: 
Use a HashSet instead of an ArrayList inside the HasMap. 

```
HashMap<String, HashSet<String>> map1 = new HashMap<>();
HashSet<String> al = new HashSet<>();
al.add("A");
al.add("B");
al.add("C");
map1.put("1", al);

```

Remove by:

```
map1.get("1").remove("B") 

```
Currently Java does not provide the support of removing an element using its value in `hashmap` so you have to iterate all the elements and fetch the `arraylist` and check that value is present or not if its present than remove that value. if the value is static you can use `map1.get("1").remove("B")` and if its dynamic than provide an input source and then iterate the map and than iterate the `arraylist` check if value persists if so than delete it `