Java - How to repopulate an arraylist with previously known elements
<p>I have an arraylist populated by four elements, the order of which is random (they are put here by random from another arraylist).  I then have a for loop that repeats 10 times, at the end of each repetition I use the clear methods to clear all the elements of the arraylist.  However, when I start a new repetition, I would like to repopulate my arraylist with the old (previously worked with) elements that were members of the list in the previous repetition, so that I can use the elements again.  And I would like to repeat that until I get out of my 10-repetition for loop.  Is there any way to achieve this at all?</p>

<p>Code in addition to my question:</p>

<pre><code> ArrayList&lt;String&gt; answerPegs =  new  ArrayList&lt;String&gt;();
  // add element to ArrayList

    ArrayList&lt;String&gt; mySecretAnswer = new ArrayList&lt;String&gt;();

    for (int n = 4; n &gt; 0; n--) 
    {       
         //populate mySecretAnswer with elements from answerPegs
    }


    ArrayList&lt;String&gt; clone1 = mySecretAnswer;

    for (int q = 0; q &lt; 10; q++) { 

        for (o = 0; o &lt; 4; o++)
        {
         }
      // called clear() method here

    } // END OF 10-ROW LOOP
</code></pre>
