This is my map with iterators to delete some data based on some conditions, now I want to run the same map in the opposite direction and conditions, respectively.
But I could not find ListIterator to return easily.
How can i do this?
Also the Map implementation that I use is TreeMap
for(int i=countIteration;i<(countIteration+2);i++) { Iterator it = imageFilexxSm.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); if(pairs.getKey().equals(data1.get(i).replace(".png", ".mp3"))) { it.remove(); } } Iterator itr = imageFilexxS.entrySet().iterator(); while (itr.hasNext()) { Map.Entry pairsx = (Map.Entry)itr.next(); if(pairsx.getKey().equals(data1.get(i))) { System.out.println("entry deleted."+pairsx.getKey()); itr.remove(); } } }
source share