title: How to get out variable from recurrence in Java?
body: <p>This is a method in Java, that(when k == 0) in int[] arr has one of k-combination int[] intems. In variable iloczyn is calculated product of elements in this combination. In tmp is calculated sum of all such products. Unfortunately, System.out.println(tmp) shows, that when function ends, tmp equals 0. This is very sad, because i need this variable for next calculations. What shoud I do?</p>
  
  <pre><code>int tmp = 0;
  public void kcomb(int[] items, int n, int k, int[] arr) 
  {
      int iloczyn = 1;
  
  
      if (k == 0) {
          for(int i = 0; i&lt; arr.length; i++){
              iloczyn*=arr[i];
          }
          tmp +=iloczyn;
  
  
      } else {
          for (int i = n; i &lt;= items.length - k; i++) {
              arr[arr.length - k] = items[i];
              kcomb(items, i + 1, k - 1, arr);
          }
      }
      System.out.println(tmp);
  }
  </code></pre>