>これまで空文字列をチェックする際
>
>hoge == null && hoge.equals("")
>のような評価を行っていたが
>
>hoge.isEmpty()
>これで上述の式と同じ評価を行えることを知った。
>これはコードがスマートになっていい
このような記述をしたのですが、完全に誤りです。失礼しました。
hoge == null の時、hoge.isEmpty()はNullPointerExceptionとなります。
(バグを出して初めて気付いた・・・)
hoge == null && hoge.equals("") を一気に行いたい場合は org.apache.commons.lang3.StringUtilsのメソッド isEmptyを利用します。
StringUtils.isEmpty(hoge);
なおorg.apache.commons.lang3パッケージのクラスの利用にあたっては、org.apache.commons.lang3ライブラリをビルドパスに追加する必要があります。
The chart beneath reveals really helpful wall thicknesses for widespread injection molding resins. The sequence of events during the injection molding of a plastic half recognized as} the injection molding cycle. The cycle begins when the mildew closes, followed by the Tent Heaters injection of the polymer into the mildew cavity.
返信削除