Comparing a string with the empty string (Java)

前端 未结 8 679
失恋的感觉
失恋的感觉 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 11:56

    It's a bit sideways from your original question, but there's always

    if(s1.length() == 0)
    

    I believe this is equivalent to isEmpty() method from 1.6.

提交回复
热议问题