Is making an empty string constant worth it?

String literals are interned by default, so no matter how many times you refer to “” in code, there will only be one empty String object. I don’t see any benefit in declaring EMPTY_STRING. Otherwise, you might as well declare ONE, TWO, THREE, FOUR, etc. for integer literals.

Of course, if you want to change the value of EMPTY_STRING later, it’s handy to have it in one place 😉

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)