public class TestString { public static void main(String[] args) { String abc = null; //先判断是否为null再判断是否为空. if(abc != null && !abc.isEmpty()) { System.out.println("true"); }else{ System.out.println("false"); } } }
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/p/6419783.html