title: Update parameters of a list in a method: return list or not
body: <p>I have a list of objects like the next class:</p>
  
  <pre><code>class A {
      private String property1;
      private String property2;
      //Setters &amp;&amp; Getters
  
  }
  </code></pre>
  
  <p>So, after some operations I need to update the list with a default value with some logic like next:</p>
  
  <pre><code> listOfA.forEach(item -&gt; { 
         item.setProperty1(findSomething());
   } 
  </code></pre>
  
  <p>This logic is repeated several times so I'm looking to export it to a method. So, my question is related to this method: Should I update the copy reference of the list with a void method, return it or create new list and update it?:</p>
  
  <p><strong>Option 1: Update the copy reference of the list</strong></p>
  
  <pre><code> private void updateList(List&lt;A&gt; listOfA) {
       listOfA.forEach(item -&gt; { 
         item.setProperty1(findSomething());
      }
   }
  </code></pre>
  
  <p><strong>Option 2: Return it</strong></p>
  
  <pre><code>private List&lt;A&gt; updateList(List&lt;A&gt; listOfA) {
       listOfA.forEach(item -&gt; { 
         item.setProperty1(findSomething());
      }
  
      return listOfA;
   }
  </code></pre>
  
  <p><strong>Option 3: Create a new list from the other, update this and return it</strong> </p>
  
  <pre><code>private List&lt;A&gt; updateList(List&lt;A&gt; listOfA) {
       List&lt;A&gt; newList = new ArrayList&lt;&gt;();
       //Logic to copy listOfA in newList....
  
       newList.forEach(item -&gt; { 
         item.setProperty1(findSomething());
      }
  
      return newList ;
   }
  </code></pre>