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

上一篇:Go语言基础之基本数据类型


下一篇:报错: error Strings must use singlequote quotes