To remove key from hashmap and rearrange keys when used in recycler view
<p>Please any one can help how to remove particular key from hashmap and then rearrange the keys in hashmap accordingly.</p>

<p>Below is my code.</p>

<pre><code>Set&lt;Integer&gt; integerSet = hashMap.keySet();
                int removekey = pos;
                ArrayList&lt;Integer&gt; integers = new ArrayList&lt;&gt;();
                for (Integer integer : integerSet) {
                    if (integer &gt; removekey) {
                        integers.add(integer);
                    }
                }

                for (Integer integer : integers) {
                    if (hashMap.containsKey(integer)) {
                        AddCardPojo pojo = hashMap.get(integer);
                        pojo.setImagCard(cardImage[integer - 1]);
                        hashMap.remove(integer);
                        hashMap.put(integer - 1, pojo);
                    }
                }[![enter image description here][1]][1]
</code></pre>

<p>I have attached screenshot of error</p>

<p><a href="https://i.stack.imgur.com/MogRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MogRG.png" alt="enter image description here"></a></p>