How do I check for nulls and empty string for a needle in a haystack?
<p>Situation: I am coming across a lot of checks in my code. And I would like to know of a way in which I can reduce them.   </p>

<pre><code>if(needle!=null &amp;&amp; haystack!=null)
{
  if(needle.length()==0)
   return true;
  else
  {
   if(haystack.length()==0)
   return false;
   else
   {
     // Do 2 for loops to check character by character comparison in a substring  
   }
 }

}
else 
 return false;
</code></pre>
