title: Java ArrayList addAll only adding 1 element?
body: <p>So I basically put some <code>Integer</code> objects in an <code>ArrayList x</code>, then put some in an <code>ArrayList y</code>, then did <code>y.addAll(x)</code>, but it seems to be only adding the first one and leaving out all the rest! Isn't it supposed to add ALL? I looked it up on Oracle and they showed what seemed to be the EXACT SAME EXAMPLE yet mine is not working properly. Here is my code:</p>
  
  <pre><code>ArrayList&lt;Integer&gt; x = new ArrayList&lt;Integer&gt;();
  Integer a = 1;
  Integer b = 2;
  Integer c = 3;
  x.add(a);
  x.add(b);
  ArrayList&lt; Integer&gt; y = new ArrayList&lt; Integer&gt;();
  y.addAll(x);
  </code></pre>
  
  <p>yet <code>y</code> seems to only have <code>1</code> in it and missing the <code>2</code> and the <code>3</code>.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>EDIT:
  Yes, sorry, I know I didn't actually add c to x yet, but even when I do, and then print y, I still get [1] instead of [1,2,3]. This is what I don't understand.</p>
  
  <pre><code>import java.util.ArrayList;
  public class SumArrayList {
  
      public static void main(String[] args) {
  
          ArrayList&lt;Integer&gt; x = new ArrayList&lt;Integer&gt;();
          Integer a = 1;
          Integer b = 2;
          Integer c = 3;
          x.add(a);
          x.add(b);
          System.out.println(x);
          //System.out.println(calculateSumArrayListHelper(x));
  
          ArrayList&lt;Integer&gt; y = new ArrayList&lt;Integer&gt;();
          y.addAll(x);
          System.out.println(y);
          //System.out.println(calculateSumArrayListHelper(y));
      }
  }
  </code></pre>
  
  <p>Here is a pic of what I see:
  <a href="http://postimg.org/image/ms0y68nnh/" rel="nofollow">http://postimg.org/image/ms0y68nnh/</a></p>