标题基本上说明了一切。我通常会在的同时进行测试string == null,因此我并不真正担心null安全测试。我应该使用哪个?
String s = /* whatever */;
...
if (s == null || "".equals(s))
{
// handle some edge case here
}
要么
if (s == null || s.isEmpty())
{
// handle some edge case here
}
关于这一点-它isEmpty()甚至做得比其他任何事情return this.equals("");或return this.length() == 0;?
慕斯709654
相关分类