Comparing a string with the empty string (Java)

前端 未结 8 680
失恋的感觉
失恋的感觉 2020-12-02 11:17

I have a question about comparing a string with the empty string in Java. Is there a difference, if I compare a string with the empty string with == or eq

8条回答
  •  旧巷少年郎
    2020-12-02 12:01

    "".equals(s)
    

    Seems to be the best option, but there is also Stringutils.isEmpty(s) contained in the Apache commons lang library

提交回复
热议问题