String string= ""
//方法一 为""返回true 负责返回false 此处返回true
System.out.println(string.isEmpty())
//方法二 为""返回true 负责返回false 此处返回true
System.out.println(string.equals(""))
//方法三 为null返回true 负责返回false 此处返回false
System.out.println(string == null)
字符串是否为空有两种:
一种是:空串
另一种是:null
判断方式如下:
String str = ""if (str != null && "".equals(str)) {
// 业务逻辑
}