参考文章:https://www.cnblogs.com/blueskyli/p/9932017.html
@Test
public void idTest() {
String str = "8";
if (str == null) { //str的值
System.out.println("str为null!" + "\t" + str); //null
}else if (str.isEmpty()) {
System.out.println("str为Empty!" + "\t" + str); //""
}else if (str.trim().equals("")) {
System.out.println("str为''!" + "\t" + str); //" "
}else if (str.trim().equals("0")) {
System.out.println("str为0!" + "\t" + str); //" 0"
}else {
System.out.println("str不为null、''、0!" + "\t" + str); //" 1"
}
}
字符串判断空
注意:String 字符串类型需要使用 equals
Integer类型使用 ==
BigDecimal使用 compareTo