title: ConcurrentModificationException with ArrayLists and HashMaps
body: <p>I've been having problems with a database functional dependency algorithm I have been developing. I am trying to calculate functional dependencies given the current level of the lattice and the list of column heads (not really relevant).</p>
  
  <p>I am trying to iterate through a list of string headers, as well as looping through the characters of each string. Reasoning with this, I then use these values to remove a string from a <code>List&lt;String&gt;</code> value in a map. The Map has structure <code>&lt;String, List&lt;String&gt;&gt;</code> and I want to simply remove a value from the <code>List&lt;String&gt;</code> values of the HashMap. <code>colHeads</code> is a <code>List&lt;String&gt;</code>.</p>
  
  <p>I am getting ConcurrentModificationException when I start to loop through the list:</p>
  
  <pre><code>for (String x: level) {
          for (char a : x.toCharArray()) {
              if (cPlusHash.get(x).contains(Character.toString(a))) {
                  if (checkFD(Arrays.asList(x.replace("a", "")), Arrays.asList(Character.toString(a)))){
                      fds.add(x.replace("a", "") +", "+ a );  
                      cPlusHash.remove(x, Character.toString(a));
  
  
  
                      for (char j : x.toCharArray()) {
                          if (colHeads.contains(Character.toString(j))) {
                              colHeads.remove(Character.toString(j));
                          }
                      }
                      for (String b : colHeads) {
                          if (cPlusHash.get(x).contains(b)) {
                              cPlusHash.remove(x, b);
                          }
                      }
                  }
              }
          }
  </code></pre>
  
  <p>I am getting the error thrown on the first line of this snippet of code. I am confused as I'm not actually trying to modify the value of the List I'm iterating through.</p>