title: How to create an Object of List<Integer> type
body: <p>I am having trouble creating and using objects to type <code>List&lt;Integer&gt;</code>. When I run the following code, I get a <code>NullPointerException</code> because the <em>Object isn't initialized</em>. </p>
  
  <pre><code>import java.util.List;
  
  public class RBTree {
  
      public static class Tree {
          public List&lt;Integer&gt; parent;
          public List&lt;Integer&gt; right;
          public List&lt;Integer&gt; left;
          public List&lt;Integer&gt; data;
          public List&lt;Boolean&gt; black;
      }
  
      public static void main (String[] args){
          Tree rb =new Tree();                
          rb.data.add(-1);
          rb.left.add(-1);
          rb.right.add(-1);
          rb.parent.add(-1);
          rb.black.add(Boolean.TRUE);
      }
  }
  </code></pre>
  
  <p>The compiler also gives me errors unless I add <code>static</code> to the <code>public static class Tree</code> line, but I don't want <code>Tree</code> to be <code>static</code> i.e. immutable.  I need to be able to use a Tree more-or-less like a <code>struct</code> in C.</p>