字符串判空

//        String s = null;
//        String s = "";
        String s ="测试";

        if (!(s == null||s.length() <= 0)){
            System.out.println("输出:"+s);
        }

 当然也可以直接使用StringUtils工具类 ,使用 isNotBlank()或者isNotEmpty()

 org.apache.commons.lang3.StringUtils;

//        String s = null;
// String s = "";
String s ="测试";

// if (StringUtils.isNotBlank(s)){
if (StringUtils.isNotEmpty(s)){
System.out.println("输出:"+s);
}
}

想看更多精彩内容,可以关注我的CSDN

我的CSDN



posted @ 2021-04-12 15:27  Yblue  阅读(92)  评论(0编辑  收藏  举报