push button to add elements from one arraylist to another keeps overwriting old elements with new ones
<p>requestMethod in RetOrReq class returns arrayList which I want to use to populate another arrayList which I will use for drawing a graph. I can't seem to figure out how to do this. when I add to new list and print, it has overridden the previous element. 
Here is code:</p>

<pre><code>    public ArrayList request2(){
        requestsArray.get(0).add(memSize/2);
        requestsArray.get(1).add("H");      
        requestsArray.get(2).add(0);
        return requestsArray;
    }

    public ArrayList request(int reqVal, int numCounter1){  
        int numCounter=numCounter1;
        request = reqVal;
        requestsArray.get(3).set(0,0);
        if(numCounter == 1){//---------------------------numCounter == 1 beginning---------------------------------
            workingVar = memSize/2; 
                    if(request&gt;workingVar){
                        requestsArray.get(3).set(0,1);
                    }
                    else{   
               reqCounter++;
        while (workingVar&gt;=request){
            workingVar = workingVar/2;
            holes2.add(workingVar);
        }
        if(workingVar&lt;request){
            workingVar=workingVar*2;
            holes2.add(workingVar);    
            holes2.remove(holes2.size()-2);
            holes2.remove(holes2.size()-1);
                }
        }
        e1=workingVar;
        }//-----------------------------------------------end of numCounter == 1 section-------------------------------------
        if(numCounter &gt; 1){
            for (int y = 0; y&lt;requestsArray.get(0).size();y++){
                if(requestsArray.get(1).get(y).equals("H")){
                    holes.add((Integer)requestsArray.get(0).get(y));
                }
            }
            //BubbleSort of holes ArrayList
            int in, out;
            for(out= holes.size()-1; out&gt;0;out--) 
                for(in =0; in&lt;out;in++)
                if(holes.get(in)&lt;holes.get(in+1)){
                    int temp1 = holes.get(in+1);
                    int temp2 = holes.get(in);
                    holes.set(in, temp1);
                    holes.set(in+1, temp2);
                }

        //calculates the value of e1 using holes array
            if(holes.isEmpty()){
                requestsArray.get(3).set(0, 1); 
            }
            else{
            for(element=holes.size()-1;element&gt;-1;element--){//starts at end of holes array loops backwards
                e1 = holes.get(element); //assigns value of each element to e1  
             if(e1&gt;=request)    //if value e1 is greater than request stop looping                                                           
                break;                        
                }

        workingVar=e1; //assign the value of e1 to workingVar
        if (request&gt;e1){
            requestsArray.get(3).set(0, 1);                   
        }
        else{
            //---------------------code for populating holes2 array---------------------------
            reqCounter++;
        if(workingVar!=request &amp;&amp; workingVar/2&gt;=request){
            while (workingVar/2&gt;=request){
                workingVar = workingVar/2;
                holes2.add(workingVar);
                }     
            if(workingVar&lt;request){
                workingVar=workingVar*2;
                holes2.add(workingVar); 
                        }
                    }
                }
            }
        }

        //Sort of Holes2 ArrayList - reorder's holes2 for initial set up and subsequent inserts
        int in, out;
        for(out= holes2.size()-1; out&gt;0;out--) 
            for(in =0; in&lt;out;in++)
            if(holes2.get(in)&gt;holes2.get(in+1)){
                int temp1 = holes2.get(in+1);
                int temp2 = holes2.get(in);
                holes2.set(in, temp1);
                holes2.set(in+1, temp2);
            }

       //-------------------------------requestsArray Setups----------------------------------------------------
            //Initial setup of requestsArray 
        if(numCounter == 1){
            if(requestsArray.get(3).get(0).equals(0)){
            requestsArray.get(0).set(0,e1);
            requestsArray.get(1).set(0,"R");
            requestsArray.get(2).set(0, reqCounter);;
            for(int i = 0; i&lt;holes2.size();i++){
                requestsArray.get(0).add(holes2.get(i));
                requestsArray.get(1).add("H");
                requestsArray.get(2).add(0);
                }
            }
            else{
                requestsArray.get(0).set(0,e1);
                requestsArray.get(1).set(0, "H");       
                requestsArray.get(2).set(0,0);
            }
        }

        //Subsequent setup of requestsArray

        int element2;           
        if(numCounter &gt;1 &amp;&amp; requestsArray.get(3).get(0).equals(0)){
            for(element2 = 0; element2&lt; requestsArray.get(0).size(); element2++){
                if((Integer)requestsArray.get(0).get(element2)==e1 &amp;&amp;requestsArray.get(1).get(element2).equals("H") ){
                    break;
                        }
            }
                if(holes2.isEmpty()){
                requestsArray.get(1).set(element2, "R");
                requestsArray.get(2).set(element2, reqCounter);
                        }
                else{ //holes2 is not empty
                    requestsArray.get(0).add(element2, workingVar);
                    requestsArray.get(2).add(element2,reqCounter);
                    requestsArray.get(1).add(element2, "R");
                    requestsArray.get(0).remove(element2+1);
                    requestsArray.get(2).remove(element2+1);
                    requestsArray.get(1).remove(element2+1);                    
                    for(int i = 1; i&lt;holes2.size()+1;i++){
                        `enter code here`requestsArray.get(0).add(element2+i,holes2.get(i-1));
                        requestsArray.get(1).add(element2+i,"H");
                        requestsArray.get(2).add(element2+i,0);
                        }
                    }                           
            }
       //---------------------------End of requestsArray Setups--------------------------------------------------

        //-----------------End Section for populating requestsArraywhen numCounter &gt; 1---------------------------           

            //remove all values from holes1 and holes2
            holes.clear();
            holes2.clear();
            return requestsArray;

            }
</code></pre>

<p>and:</p>

<pre><code>public class panel1 extends JPanel  {   
private JPanel pane1;
private JPanel pane2;
private JPanel spacer1;
private JPanel spacer2;
private JPanel spacer3;

private JLabel titleLabel;
private JLabel requestLabel;
private JLabel returnLabel1;
private JLabel returnLabel2;

private JTextField requestor;
private JTextField returnRequest;
private JButton requestButton;
private JButton returnButton;

private ArrayList&lt;ArrayList&gt;req01;
private ArrayList&lt;ArrayList&gt; results1;

private int memSize = 1024;

private ReqOrRet requestor1;
private int numItr = 0;

public panel1(){                        
pane1 = new JPanel();
pane2 = new JPanel();
spacer1 = new JPanel();
spacer2 = new JPanel();
spacer3 = new JPanel();
titleLabel = new JLabel();
requestLabel = new JLabel();
returnLabel1 = new JLabel();
returnLabel2 = new JLabel();

requestor = new JTextField();
requestor.setPreferredSize(new Dimension(145,20));
returnRequest = new JTextField();
returnRequest.setPreferredSize(new Dimension(145,20));
requestButton = new JButton("Submit");
returnButton = new JButton("Submit");
requestLabel.setText("Please enter a request");
requestLabel.setFont(new Font("Helvetica", Font.BOLD, 15));
requestLabel.setForeground(Color.white);

returnLabel1.setText("Enter Request Number\n");

returnLabel1.setFont(new Font("Helvetica", Font.BOLD, 15));
returnLabel1.setForeground(Color.white);
returnLabel2.setText("to return");

returnLabel2.setFont(new Font("Helvetica", Font.BOLD, 15));
returnLabel2.setForeground(Color.white);

titleLabel.setText("Buddy System"); 
titleLabel.setForeground(Color.white);
titleLabel.setFont(new Font("Helvetica", Font.BOLD, 75));

spacer1.setPreferredSize(new Dimension(165,100));
spacer1.setBackground(Color.black);
spacer1.add(requestLabel);
spacer1.add(requestor);
spacer1.add(requestButton);
spacer3.setPreferredSize(new Dimension(165,100));
spacer3.setBackground(Color.black);
spacer3.add(returnLabel1);
spacer3.add(returnRequest);
spacer3.add(returnButton);
spacer2.setPreferredSize(new Dimension(300,100));
spacer2.setBackground(Color.black);
spacer3.setPreferredSize(new Dimension(300,100));

pane1.setBackground(Color.black);   
pane1.setPreferredSize(new Dimension(165,800));
pane1.add(spacer1);
pane1.add(spacer3);

pane2.setBackground(Color.black);
pane2.setPreferredSize(new Dimension(800,100));
pane2.add(spacer2);
pane2.add(titleLabel);

setLayout(new BorderLayout());
add(pane1, BorderLayout.WEST);
add(pane2, BorderLayout.NORTH);

requestor1 = new ReqOrRet(memSize);
req01 = requestor1.request2();
requestButton.addActionListener(new ButtonListener());
}   
private class ButtonListener implements ActionListener{
public  void actionPerformed (ActionEvent e){
    int reqVal = 0;
    String reqVal1;
    numItr++;   

    req01 = new ArrayList&lt;ArrayList&gt;();

    ArrayList&lt;ArrayList&gt; req03 = new ArrayList&lt;ArrayList&gt;();

    reqVal1 = requestor.getText();

    reqVal = Integer.parseInt(reqVal1);
        req03 = requestor1.request(reqVal, numItr);

        results1 = new ArrayList&lt;ArrayList&gt;();
            if(req03.get(3).get(0).equals(0)){          
                req01 = req03;
                }
            results1.add(req01);

            System.out.print(results1);

        }
}
</code></pre>

<p>}</p>
