ArrayList of ArrayLists.. Unable to refer to them multiple times
<p>Here is a particular method I have written:</p>

<pre><code>class A {

    private static ArrayList&lt;ArrayList&lt;Integer&gt;&gt; inputTerms = 
                                              new ArrayList&lt;ArrayList&lt;Integer&gt;();

    public static void method1(ArrayList&lt;Integer&gt; terms) {

        int N = terms.size();
        for (int i = 0; i &lt; N - 1; i++) {
            for (int j = i + 1; j &lt; N; j++) {
                ArrayList&lt;Integer&gt; clauses = new ArrayList&lt;Integer&gt;();
                clauses.add(-terms.get(i));
                clauses.add(-terms.get(j));
                inputTerms.add(clauses);
            }
        }
    }
}
</code></pre>

<p>In my main function, i have the following code:</p>

<pre><code>for (int i=0; i&lt;N-1; i++){ 
   ArrayList&lt;Integer&gt; firstdiagonalTerms = new ArrayList&lt;Integer&gt;(); 
   for (int j=0; j&lt;N-i; j++){ 
      firstdiagonalTerms.add(variable[j][i+j]); 
   } 
   method1(firstdiagonalTerms);
} 
</code></pre>

<p>I have 4 such double for-loops in my main function where i call method1 for different iterations.
However, while the 1st for-loop gives the approppriate answer, the minute i declare an ArrayList inside my 2nd for loop, my inputTerns variable gets set to null. How do i overcome this?</p>
