tag:blogger.com,1999:blog-8712770457197348465.post2961773567274077806..comments2024-03-28T02:47:19.159-07:00Comments on Javarevisited: How to delete a key value pair from a HashMap during Iteration in Java - Example tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8712770457197348465.post-61457385341390010452022-03-10T00:40:00.419-08:002022-03-10T00:40:00.419-08:00Hi Javin Paul, I think you can add removeIf() meth...Hi Javin Paul, I think you can add removeIf() method that's present from Java 8 to this article. It will be helpful for many like me.rajeevhttps://www.blogger.com/profile/12389753554368693357noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-80346501756388084722022-03-10T00:39:01.732-08:002022-03-10T00:39:01.732-08:00@Ana, with iterator you can remove elements, but c...@Ana, with iterator you can remove elements, but can't add elements to the map. If you use for loop, you can neither remove nor add elements. If you want to both add and remove then ConcurrentHashMap should be used.rajeevhttps://www.blogger.com/profile/12389753554368693357noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-1282365957918357762018-12-06T01:03:40.721-08:002018-12-06T01:03:40.721-08:00@Ana, I run the code which you shared but I got Co...@Ana, I run the code which you shared but I got ConcurrentModificationExceptionAshish Agarwalhttps://www.blogger.com/profile/06257361946396435667noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-89069589186278207672018-01-05T10:53:47.552-08:002018-01-05T10:53:47.552-08:00void testFinal(final int x, A testa){
tes... void testFinal(final int x, A testa){<br /> testa = new A();<br /> HashMap hm = new HashMap();<br /> hm.put("Akey", 1);<br /> hm.put("Bkey",2);<br /> hm.put("Ckey",3);<br /> hm.put("Dkey",4);<br /> hm.put("Ekey",5);<br /> <br /> Set> setOfEntries = hm.entrySet();<br /> Anonymoushttps://www.blogger.com/profile/11972124267243655726noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-67615364247520628732018-01-04T04:53:26.128-08:002018-01-04T04:53:26.128-08:00Hello Ana, sounds interesting, can you please post...Hello Ana, sounds interesting, can you please post your full code here? javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-7022261091977735592018-01-03T21:40:56.474-08:002018-01-03T21:40:56.474-08:00I am using Java1.8.0_65
I dont see concurrentModif...I am using Java1.8.0_65<br />I dont see concurrentModificationException while using map's remove method.Anonymoushttps://www.blogger.com/profile/11972124267243655726noreply@blogger.com