在比较时使用Objects.equals()方法或使用StringUtils.isNotEmpty()方法进行非空检查。
示例代码:
String str = null; if (Objects.equals(str, null)) { System.out.println("str is null"); }
if (StringUtils.isNotEmpty(str)) { System.out.println("str is not empty"); }
下一篇:变量显示为未定义。