title: Return empty collection from a method
body: <p>Is there any memory/performance benefit of using the first method over the second?</p>
  
  <p>First</p>
  
  <pre><code>public List&lt;Integer&gt; getList1(List&lt;Integer&gt; data) {
      List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
      for (Integer element: data) {
          if (element % 2 == 0) {
             list.add(element);
          }
      }
      return list.isEmpty() ? Collections.&lt;Integer&gt;emptyList() : list;
  }
  </code></pre>
  
  <p>Second</p>
  
  <pre><code>public List&lt;Integer&gt; getList2(List&lt;Integer&gt; data) {
      List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
      for (Integer element: data) {
          if (element % 2 == 0) {
             list.add(element);
          }
      }
      return list;
  }
  </code></pre>