这两种字符串判断为空,有区别吗?

String mobile = member.getMobile();
String password = member.getPassword();

第一种
if (mobile.isEmpty() || password.isEmpty())

第二种
if(StringUtils.isEmpty(mobile) || StringUtils.isEmpty(password))

看下源码就知道了,第二种方式涵盖了第一种方式,实际使用更全面

第一种null没有判断,直接点就有可能npe

第一种,在mobile或者password 为null的时候第一个if判断空字符串会抛出NPE异常
第二种,使用工具类判断具体得看这个工具类里面的方法实现,一般来说工具类中的方法都会有类似 null != mobile && 0 != mobile.len