public void execute(HashMap<String,Coordonnee >c)
{
    c.forEach((k,v) -> {
        p = m.getMin(c);
        sky.add(p);
        c.remove(p.getNom());
    });
}
This throws a java.util.ConcurrentModificationException.
How can I fix that ?
public void execute(HashMap<String,Coordonnee >c)
{
    c.forEach((k,v) -> {
        p = m.getMin(c);
        sky.add(p);
        c.remove(p.getNom());
    });
}
This throws a java.util.ConcurrentModificationException.
How can I fix that ?
 
    
     
    
    map.entrySet().removeIfUse iterator:
Iterator<Object> it = map.keySet().iterator();
while (it.hasNext())
{
   it.next();
   if (something)
       it.remove();
}
 
    
    you cannot delete an element of the list while looping through it. You should use Iterator for that.
public void execute(HashMap<String,Coordonnee >c)
{
    Iterator cItr = c.iterator();
    while(cItr.hasNext())
    {
        c = cItr.next();
        p = m.getMin(c);
        sky.add(p);
        cItr.remove(p.getNom());
    }
}
