Best way to verify string is empty or null

前端 未结 13 809
野的像风
野的像风 2020-12-14 15:30

i am sure this must have been asked before in different ways - as isEmptyOrNull is so common yet people implement it differently. but i have below curious query in terms of

13条回答
  •  春和景丽
    2020-12-14 15:51

    With the openJDK 11 you can use the internal validation to check if the String is null or just white spaces

    import jdk.internal.joptsimple.internal.Strings;
    ...
    
    String targetString;
    if (Strings.isNullOrEmpty(tragetString)) {}
    

提交回复
热议问题