Is making an empty string constant worth it?

前端 未结 18 854
無奈伤痛
無奈伤痛 2021-01-01 10:11

I have a co-worker that swears by

//in a singleton \"Constants\" class
public static final String EMPTY_STRING = \"\";

in a constants class

18条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 10:50

    I don't like either choice. Why not if (otherString.length() == 0)

    Edit: I actually always code

    if (otherString == null || otherString.length() == 0)
    

提交回复
热议问题