title: addAll() implementation -- Java
body: <p><strong>addAll()</strong> of <strong>AbstractCollection</strong> is implemented as follows: </p>
  
  <pre><code>public boolean addAll(Collection&lt;? extends E&gt; c) { 
      boolean modified = false;
      for (E e : c) if (add(e)) modified = true; 
      return modified;
  }
  </code></pre>
  
  <p>So, if <strong>c</strong> in the parameter is a collection of, say 3 elements, it may be the case that first 2 
  of these elements are added, but the 3rd isn't added for some reason i can't think of right now. </p>
  
  <p>In this case, the <strong>addAll()</strong> operation-- the addition of all of these 3 elements to the underlying 
  Collection isn't carried and <strong>addAll()</strong> is returning false as it should. However, the first 2 elements are there-- and the developer 
  would expect they shouldn't be(?)</p>
  
  <p><strong>HashSet</strong> is using this <strong>addAll()</strong> in its constructor-with-a-single-param that is of type Collection. </p>
  
  <p>So, the developer could end up with a <strong>HashSet</strong> instance 
  that contains a part of his collection while he`s looking for the entire collection. And this happens without any warnings. </p>
  
  <p>The methods involved--  <strong>put()</strong> of <strong>HashMap</strong> and <strong>add()</strong> of <strong>HashSet</strong> seem straightforward enough-- 
  doesn`t seem anything can go wrong during these operations-- but still. </p>
  
  <p>Am i missing something here?</p>