title: java multidimensional arraylist
body: <p>I just wrote this function to add values into Multidimensional arraylist, but dont get it why all added values overwrites into recent added value. I need to figure out why this happening. As javadoc says it has to act like this " Appends the specified element to the end of this list". And i dont see any place at his code, where previously added value could be overwriten . One more strange thing is that size of array increases</p>
  
  <p>Here is my output:</p>
  
  <p><code>
      [0.4, 0.42, 0.4, 1.2200000000000002, 0.0010000000000000009]  after add 0
      [0.4, 0.42, 0.4, 1.2200000000000002, 0.0010000000000000009]  after add 1
      [0.4, 0.42, 0.4, 1.2200000000000002, 0.0010000000000000009]  after add 2
      [0.4, 0.42, 0.4, 1.2200000000000002, 0.0010000000000000009]  after add 3
      [0.4, 0.42, 0.4, 1.2200000000000002, 0.0010000000000000009]  after add 4
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 0
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 1
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 2
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 3
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 4
      [0.4, 0.42, 0.42, 1.24, 0.01200000000000001]  after add 5
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 0
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 1
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 2
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 3
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 4
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 5
      [0.4, 0.44, 0.4, 1.2400000000000002, 0.011999999999999983]  after add 6</code></p>
  
  <p>And here is my function:</p>
  
  <pre><code>public void createArrayList(ArrayList&lt;Double&gt; list,ArrayList&lt;Double&gt;
  listLaid,int size,double sum, double absValue){   
  ArrayList&lt;Double&gt; workArray = new ArrayList&lt;&gt;();  
  ArrayList&lt;ArrayList&lt;Double&gt;&gt;
  workMatrix= new ArrayList&lt;&gt;();
  
  double abs=0;
  for(int a = 0; a &lt; size ;a++){
       for(int b = 0; b &lt; size ; b++){
             for (int c = 0 ; c &lt; size; c++){
  
               abs =Math.abs(sum - list.get(a) - list.get(b) - list.get(c));
                   if( abs &lt;= absValue){
                         double totalSum = listLaid.get(a) + listLaid.get(b) +                                            
                                           listLaid.get(c);
                         workArray.clear();
                         workArray.add(listLaid.get(a));
                         workArray.add(listLaid.get(b));
                         workArray.add(listLaid.get(c));
                         workArray.add(totalSum);
                         workArray.add(abs);
  
                         workMatrix.add(workArray);
  
                    }
                }
           } 
      }                   
  } 
  for (int i = 0; i &lt; workMatrix.size(); i++)   
  System.out.println(darbineMat.get(i)+"  after add  "+i);
  </code></pre>