title: Distinction between the capacity of an array list and the size of an array
body: <p>I read the below snippet in Core Java I book.</p>
  
  <blockquote>
    <p>Allocating an array list as
    <strong>new ArrayList &lt;'Employee>(100) // capacity is 100</strong></p>
    
    <p>is not the same as allocating a new array as
    <strong>new Employee[100] // size is 100</strong></p>
    
    <p>There is an important distinction between the capacity of an array list and the size of an
    array. If you allocate an array with 100 entries, then the array has 100 slots, ready for use.
    An array list with a capacity of 100 elements has the potential of holding 100 elements (and,
    in fact, more than 100, at the cost of additional reallocations); but at the beginning, even
    after its initial construction, an array list holds no elements at all.</p>
  </blockquote>
  
  <p>When I saw the source code array list, the constructor creates of an Object array of given capacity which is ready to hold elements of given capacity (below is the code snippet). </p>
  
  <pre><code>public ArrayList(int initialCapacity) {
       super();
       if (initialCapacity &lt; 0)
           throw new IllegalArgumentException("Illegal Capacity: "+
                                              initialCapacity);
       this.elementData = new Object[initialCapacity];
   }
  </code></pre>
  
  <p>I am not able to figure out the actual difference what the author has mentioned in above text. </p>