O título basicamente diz tudo. Normalmente, estou testando isso ao lado de a string == null, então não estou realmente preocupado com um teste com segurança nula. Qual devo usar?
String s = /* whatever */;
...
if (s == null || "".equals(s))
{
// handle some edge case here
}
ou
if (s == null || s.isEmpty())
{
// handle some edge case here
}
Na mesma nota - faz isEmpty()mesmo outra coisa senão return this.equals("");ou return this.length() == 0;?
isEmpty()é apenas Java 6+.