title: Why does my method return the wrong value?
body: <p>Even though my method <em>operationsNeeded</em> prints the correct value for my return-int "count1", the very next line it returns something else to my main method. I did not include the rest of my code, if needed I'd gladly provide it. 
  For example if <em>operationsNeeded</em> is executed 4 times, <em>count1</em> is on 4 which is printed out as well. But for reasons unknown to me the System.out.println("check: " +count1); Statement is executed 4 times like this:<br>
  <strong>check: 4<br>
  check: 4<br>
  check: 3<br>
  check: 2</strong><br>
  I would expect my program to execute this only once and then continue to the return statement. </p>
  
  <pre><code>public static void main(String[] args) {
  
      Scanner sc = new Scanner(System.in);
      int testcases = sc.nextInt();
      int count =0;
      while (count&lt;testcases){
          int numberOfColleagues = sc.nextInt();
          sc.nextLine();
          String startPieces = sc.nextLine();
  
          int[] listOfcolleagues = listOfColleagues(numberOfColleagues, startPieces);
  
          int count2 = operationsNeeded(listOfcolleagues, 1);
          count++;
          System.out.println(count2);
      }
  
  }
  
   public static int operationsNeeded (int[] listOfColleagues, int count1){
      //remove duplicates first
      ArrayList&lt;Integer&gt; relevantList=removeDuplicatesAndSort(listOfColleagues);
      System.out.println("relevantlist" + relevantList);
      //check for smallestdelta &amp; index
      int [] deltaAndIndex = smallestDeltaHigherIndex(relevantList);
      int delta = deltaAndIndex[0];
      int index = deltaAndIndex[1];
  
      if (delta==1){
          for (int i=0;i&lt;relevantList.size();i++){
              if (i!=index){
                  relevantList.set(i,relevantList.get(i)+1);
              }
  
          }
      }
      if (delta&gt;1 &amp;&amp; delta&lt;5){
          for (int i=0;i&lt;relevantList.size();i++){
              if (i!=index){
                  relevantList.set(i,relevantList.get(i)+2);
              }
          }
      }
      if (delta&gt;4){
          for (int i=0;i&lt;relevantList.size();i++){
              if (i!=index){
                  relevantList.set(i,relevantList.get(i)+5);
              }
          }
      }
  
      System.out.println(count1);
      int[] updatedList = new int[relevantList.size()];
      for (int i=0; i&lt;relevantList.size();i++){
          updatedList[i]=relevantList.get(i);
      }
      if (!isAllTheSame(relevantList)) {
          count1 +=1;
          operationsNeeded(updatedList,count1);
      }
  
          System.out.println("check: " + count1);
  
   return count1;
  }
  </code></pre>