title: java: returning a collection
body: <p>What's the best way to return a collection in Java?</p>
  
  <p>Should I allow the caller to provide a collection to add to? Or just return a <code>List&lt;&gt;</code> or <code>Set&lt;&gt;</code> of items? Or both?</p>
  
  <pre><code>public class Item { ... }
  
  public class SomeOtherClass
  {
    private List&lt;Item&gt; myItems;
  
    public List&lt;Item&gt; getItems()
    { 
       return Collections.unmodifiableList(this.myItems); 
    }
    public void collectItems(Collection&lt;? super Item&gt; target)
    {
       target.addAll(myItems);
    }
  }
  </code></pre>
  
  <p><strong>note:</strong> the above example assumes the pre-existence of a list that can be instantly returned. I am also interested in the appropriate answer when such a list does not previously exist and must be generated when the caller calls getItems() or collectItems().
  (I have renamed collectItems based on the point raised by Mykola.)</p>