Java equals() ordering

后端 未结 6 944
执念已碎
执念已碎 2021-01-12 02:55

If I try to do a .equals() on a null string in java, a null pointer exception will be thrown. I am wondering, if I am trying to compare if a string is equal to

6条回答
  •  自闭症患者
    2021-01-12 03:34

    is this just really poor code?

    No, this is the way many people would code the statement to avoid NPE.

提交回复
热议问题