環境

なぜ

StringUtils.hasLengthがおすすめ

if(StringUtils.hasLength(文字列)){
    文字列 is not empty
} else {
    文字列 is empty
}


いろいろな判定方法

if(StringUtils.isEmpty(文字列)){
if(文字列.isEmpty()){ 
if(文字列.equals("") || 文字列.equals(null)) {


まとめ


参考文献

https://spring.pleiades.io/spring-framework/docs/current/javadoc-api/org/springframework/util/StringUtils.html#StringUtils–


未経験から開発エンジニアに【Javaコース】

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です