title: ArrayList Method Returns a null ArrayList, main program cannot access
body: <p>I'm trying to create a basic function that calls on a method that creates the 2D ArrayList that will be used further in the main program to do things like calculate the row and column sums as well as print out the triangle.
  However, after it runs the ArrayList returns null. What's going on?</p>
  
  <p>Thanks, </p>
  
  <pre><code>public class Trib
  {
  private ArrayList&lt;ArrayList&lt;Integer&gt;&gt; triangle;
  private int Asize;
  
  public Trib (int size)
  {
      // convert the argument to type 'int' to be used in the program
      Asize = size; 
      // create an ArrayList of ArrayLists, it will have 'size' number     ArrayLists contained within
      ArrayList&lt;ArrayList&lt;Integer&gt;&gt; triangle = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(size);
  
      // create the inner ArrayLists
      for (int i = 0; i &lt; size; i++)
      {
          // add to index 'i' of our ArrayList a new ArrayList of size (i+1)
          triangle.add(new ArrayList&lt;Integer&gt;(i+1));
          for (int j = 0; j &lt;= i; j++)
          {
  
              if (j==0 || j == i)
              {
                  triangle.get(i).add(1);
              }
              else
                  triangle.get(i).add(triangle.get(i-1).get(j-1)+triangle.get(i-1).get(j));
  
              System.out.print(triangle.get(i).get(j) + " ");
          }
          System.out.println();
      }
      triangle.clone();
  
  }
  
  
  public void printTriangle()
  {
      System.out.print(triangle.get(1).get(1));
      /*for (int i = 0; i &lt; Asize; i++)
      {
          for (int j = 0; j &lt;= i; j++)
          {
              System.out.print(triangle.get(1).get(1) + " ");
          }
          System.out.println();
      }*/
  }
  /*public Trib()
  {
      this(5);
  }*/
  
  /*public int Psize()
  {
      return triangle.size();
  }
  
  public ArrayList&lt;Integer&gt; sumRows()
  {
      ArrayList&lt;Integer&gt; row_sum = new ArrayList&lt;Integer&gt;(Asize);
      for (int i = 0; i &lt; Asize; i++)
      {
          for (int j = 0; j &lt; i; j++)
          {
              row_sum.add(triangle.get(i).get(j));
          }
      }
      return row_sum;
  }
  
  public ArrayList&lt;Integer&gt; sumCols()
  {
      ArrayList&lt;Integer&gt; col_sum = new ArrayList&lt;Integer&gt;(Asize);
      for (int i = 0; i &lt; Asize; i++)
      {
          for (int j = 0; j &lt; i; j++)
          {
              col_sum.add(triangle.get(i).get(i));
          }
      }
      return col_sum;
  }*/
  
  public static void main(String[] args)
  {
      if(args.length &lt; 1)
      {
          System.err.println("Sorry, this program needs an integer argument.");
          System.exit(1);
      }
  
  
      Trib pt = new Trib(Integer.parseInt(args[0]));
      pt.printTriangle();
  
      //ArrayList&lt;Object&gt; sum_rows =  new ArrayList&lt;Object&gt;(pt.Psize());
      // sum_rows.add;
  
      System.out.println("\nHere are the sum of rows:");
  
      //for (int i = 0; i &lt; pt.Psize(); i++)
          //System.out.println(sum_rows.get(i));
  
      //ArrayList&lt;Integer&gt; sum_cols = new ArrayList&lt;Integer&gt;(pt.Psize());
  
      System.out.println("\nHere are the sum of columns:");
  
      //for (int i = 0; i &lt; pt.Psize(); i++)
          //System.out.printf("%-5d", sum_cols.get(i));
  
  }
  </code></pre>
  
  <p>}</p>