情况:我在代码中遇到很多检查。我想知道一种我可以减少它们的方法。如何检查干草堆中针头的零位和空串?
if(needle!=null && 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;
谢谢史蒂夫! – phoenix