title: Why is it considered good practice to return an empty collection?
body: <p>I have read several books and seen several blogs discussing how returning an empty collection is better than returning null. I completely understand trying to avoid the check, but I don't understand why returning an empty collection is better than returning null. For example:</p>
  
  <pre><code>public class Dog{
  
     private List&lt;String&gt; bone;
  
     public List&lt;String&gt; get(){
         return bone;
     }
  
  }
  </code></pre>
  
  <p>vs</p>
  
  <pre><code> public class Dog{
  
     private List&lt;String&gt; bone;
  
     public List&lt;String&gt; get(){
         if(bone == null){
          return Collections.emptyList();
         }
         return bone;
     }
  
  }
  </code></pre>
  
  <p>Example one will throw a NullPointerException and example two will throw an UnsupportedOperation exception, but they are both very generic exceptions. What makes one better or worse than the other?</p>
  
  <p>Also a third option would be to do something like this:</p>
  
  <pre><code> public class Dog{
  
     private List&lt;String&gt; bone;
  
     public List&lt;String&gt; get(){
         if(bone == null){
          return new ArrayList&lt;String&gt;();
         }
         return bone;
     }
  
  }
  </code></pre>
  
  <p>but the problem with this is that you're adding unexpected behavior to your code which others may have to maintain. </p>
  
  <p>I'm really looking for a solution to this predicament. Many people on blogs tend to just say it is better without an detailed explanation as to why. If returning an immutable list is best practice I am ok doing it, but I would like to understand why it is better. </p>