title: NullPointerException in TreeSet when removeAll()
body: <p>From the docs of <a href="https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html#removeAll(java.util.Collection)" rel="nofollow noreferrer"><code>Collection.removeAll()</code></a>:</p>
  
  <blockquote>
    <p><strong>Throws:</strong> <code>NullPointerException</code> - if this collection contains one or more 
    null elements and the specified collection does not support 
    null elements (optional), or if the specified collection is null.</p>
  </blockquote>
  
  <p>But the code below does still throw a <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html" rel="nofollow noreferrer"><code>NullPointerException</code></a>:</p>
  
  <pre><code>public class TestSet { 
      public static void main(String[] args) { 
          Set set1 = new TreeSet(); 
          set1.add("A"); 
          set1.add("B"); 
          Set set2 = new HashSet(); 
          set2.add(null); 
          set1.removeAll(set2); 
      } 
  } 
  </code></pre>
  
  <p>Can someone help me understand this behavior?</p>