title: list of integer arrays is changed java
body: <p>I am using a list of integer arrays, which is a class variable, to hold the answers. The integer arrays are added to the list in a method, and the results are fine (has 1s). But when I fetch it in main method, the value in it is all 0s! I do not understand, where is the list changed?</p>
  
  <pre><code>public class test {
  private static int sum=0;
  static ArrayList&lt;Integer[]&gt; res = new ArrayList&lt;Integer[]&gt;();
  private static double max=0;
  
  public static void main(String[] args) {
      int n = 6;
      double B = 23.6;
      double[] menu = { 1.2, 2, 2.5, 3.5, 3.2, 6.2, 7.8, 4.0, 5.6, 10, 6.5 };
      Integer[] solution = new Integer[menu.length];
      combinate(menu, 0, n,0, res, solution);
      for(int i=0;i&lt;res.size();i++) {
          //not getting the element!!!!!!!!!!!!
          //Integer[] sol = res.get(i);
          System.out.println(i+" "+res.get(i));
          System.out.println("Arraylist contains:"+Arrays.toString( res.get( i ) ) );
  
          double sums = 0.0;
          for (int j = 0; j &lt; res.get(i).length; j++) {
              if(res.get(i)[j]!=null)
                  sums += menu[j] * res.get(i)[j];
          }
          if (max &lt; sums &amp;&amp; sums &lt; B) {
              max = sums;
          }
      }
      System.out.println(max + " max");
  }
  
  public static void combinate(double[] left, int n, int k,int sum,
          ArrayList&lt;Integer[]&gt; res, Integer[] holder) {
      if (n == left.length) {
          if (sum == k) {
              res.add(holder);
              System.out.println(res.size()+" "+Arrays.toString(res.get(res.size()-1)));
          }
          sum = 0;
          return;
      }
      {
          holder[n] = 1;
          sum++;
          combinate(left, n + 1, k, sum,res, holder);
          holder[n] = 0;
          sum--;
          combinate(left, n + 1, k, sum,res, holder);
      }
  }
  </code></pre>
  
  <p>}
  }</p>
  
  <p>The answers looks like this:
  when print in method combinate, the list elements looks like [1111100000]</p>
  
  <p>while in main method, there are all [000000000000]</p>
  
  <p>what goes wrong here?</p>