Strings.isEmpty()和Strings.isBlank()的区别
作者:互联网
Strings.isEmpty()-----当str为null或""时返回true,其他情况返回false
Strings.isBlank()-----当str为null,"",或空白字符时返回true,其他情况返回false
System.out.println(Strings.isEmpty(null));//true System.out.println(Strings.isEmpty("")); // true System.out.println(Strings.isEmpty(" ")); //false System.out.println(Strings.isEmpty("bob")); //false System.out.println(Strings.isEmpty(" bob "));//false ---------------------------------------------------------------- System.out.println(Strings.isBlank(null)); //true System.out.println(Strings.isBlank(""));//true System.out.println(Strings.isBlank(" "));// true System.out.println(Strings.isBlank("\t \n \f \r"));//true //对于制表符、换行符、换页符和回车符 System.out.println(Strings.isBlank("bob"));//false System.out.println(Strings.isBlank(" bob "));//false System.out.println(Strings.isBlank("\b")); //false //"\b"为单词边界符
参考自csdn博客:https://blog.csdn.net/lazy_cat_go/article/details/105280664
标签:false,System,isBlank,isEmpty,println,Strings,out 来源: https://www.cnblogs.com/kimhank/p/14954037.html