The title basically says it all. I'm usually testing this alongside a string == null
, so I'm not really concerned about a null-safe test. Which should I use?
String s = /* whatever */;
...
if (s == null || "".equals(s))
{
// handle some edge case here
}
or
if (s == null || s.isEmpty())
{
// handle some edge case here
}
On that note - does isEmpty()
even do anything other than return this.equals("");
or return this.length() == 0;
?