title: java.lang.UnsupportedOperationException when combining two Sets
body: <p>I have 2 different instances of HashMap</p>
  
  <p>I want to merge the keysets of both HashMaps;</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>Set&lt;String&gt; mySet = hashMap1.keySet();
  mySet.addAll(hashMap2.keySet());
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>java.lang.UnsupportedOperationException
      at java.util.AbstractCollection.add(AbstractCollection.java:238)
      at java.util.AbstractCollection.addAll(AbstractCollection.java:322)
  </code></pre>
  
  <p>I don't get a compile warning or error.</p>
  
  <p>From java doc this should work. Even if the added collection is also a set:</p>
  
  <p><strong>boolean addAll(Collection c)</strong></p>
  
  <blockquote>
    <p>Adds all of the elements in the specified collection to this set if
    they're not already present (optional operation). If the specified
    collection is also a set, the addAll operation effectively modifies
    this set so that its value is the union of the two sets. The behavior
    of this operation is undefined if the specified collection is modified
    while the operation is in progress.</p>
  </blockquote>