El título básicamente lo dice todo. Por lo general, estoy probando esto junto con un string == null, así que no estoy realmente preocupado por una prueba nula-segura. ¿Cuál debería usar?
String s = /* whatever */;
...
if (s == null || "".equals(s))
{
// handle some edge case here
}
o
if (s == null || s.isEmpty())
{
// handle some edge case here
}
En esa nota, ¿ isEmpty()hace algo más que return this.equals("");o return this.length() == 0;?
isEmpty()es Java 6+.