title: What is the Size of an Arraylist containing null object along with other Object in Java?
body: <p>I have an <code>ArrayList</code> which contains some Objects as well as some <code>null</code> elements.</p>
  
  <p>It seems the <code>null</code> is not occupying any space and the array size returned is only that occupied by the object, and doesn't take into account the 'null' elements.</p>
  
  <pre><code>//Inside for loop 
  private void addPhone(ArrayList&lt;PhoneBean &gt; phoneBeanList,Member member) {
      if ("A".equalsIgnoreCase(member.getStatus())) {
          PhoneBean phoneBean = new PhoneBean ();
          phoneBean .setPhNum("12345");
          phoneBeanList.add(phoneBean);   
      }else {
          phoneBeanList.add(null);
  
      } 
  }
  </code></pre>
  
  <p>When <code>addPhone()</code> runs twice I am expecting the <code>phoneBeanList</code> size to return 2 but instead its 1.
  Is it because <code>null</code> does not contribute to the <code>ArrayList</code> size?</p>
  
  <p>Any idea what do I need to change/add into the list if the status is anything other than <code>A</code> ?</p>