This code should create a set of numbers (Set), place the 20 different numbers into it and remove from the set all the numbers greater than 1. But when I run it an error occurred: ConcurrentModificationException,
public class Solution
{
public static void main(String[] args) throws Exception
{
    HashSet<Integer> a= createSet();
    a.addAll(removeAllNumbersMoreThan10(a));
    for (Integer nr: a)
        System.out.println(nr);
}
public static HashSet<Integer> createSet()
{
    //add your code here
    HashSet<Integer> set = new HashSet<Integer>();
    for(int i = 0; i < 20; i++)
    {
        set.add(i);
    }
    return set;
}
public static HashSet<Integer> removeAllNumbersMoreThan10(HashSet<Integer> set)
{
    //add your code here
    for (Integer nr: set)
    {
        //System.out.println(nr);
        if (nr > 10)
        {
            set.remove(nr);
        }
    }
    return set;
}
}
 
     
    