How can i reset arrylist in each loop of for?
<p>I have an Integer arraylist . I want clear it in each for and then fill it again.My code is:</p>

<pre><code>private static int myMethod(int prim){

    ArrayList&lt;ArrayList&lt;Integer&gt;&gt; number = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
    ArrayList&lt;Integer&gt; sublist = new ArrayList&lt;Integer&gt;();
    ArrayList&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;();

    for (int x = 2; x &lt; prim; x++ ){

        for (int power = 0; power &lt; prim - 1; power++){ 
            // in this loop sublist 
            //will be fill
            int i=(int)((Math.pow(x, power))%prim);
            sublist.add(i);     
        }

        number.add(sublist);

    }
}
</code></pre>

<p>prim is for example 7 ,so i want have number array list so this =>  </p>

<pre><code>[[1,2,4,1,2,4][1, 3, 2, 6, 4, 5]...] 
</code></pre>

<p>but number arraylist has this form:  </p>

<pre><code>[[1,2,4,1,2,4,1, 3, 2, 6, 4, 5][1,2,4,1,2,4,1, 3, 2, 6, 4, 5]]
</code></pre>

<p>Please help me :(</p>
