Is making an empty string constant worth it?

前端 未结 18 800
無奈伤痛
無奈伤痛 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条回答
  •  执念已碎
    2021-01-01 10:51

    The same argument comes up in .NET from time to time (where there's already a readonly static field string.Empty). It's a matter of taste - but personally I find "" less obtrusive.

提交回复
热议问题