Would it be useful to have method return values for null objects?
<p>Would it be useful to be able to provide method return value for null objects?</p>

<p>For a List the null return values might be:</p>

<pre><code>get(int) : null
size() : 0
iterator() : empty iterator
</code></pre>

<p>That would allow the following code that has less null checks.</p>

<pre><code>List items = null;

if(something) {
    items = ...
}

for(int index = 0; index &lt; items.size(); index++) {
    Object obj = items.get(index);
}
</code></pre>

<p>This would only be used if the class or interface defined it and a null check would still work.  Sometimes you don't want to do null checks so it seems like it could be beneficial to have this as an option.</p>

<p>From: <a href="http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html" rel="nofollow">http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html</a></p>
