Is StringUtils.EMPTY recommended?

keuleJ picture keuleJ · Nov 4, 2010 · Viewed 77.6k times · Source

Do you use StringUtils.EMPTY instead of ""?

I mean either as a return value or if you set a the value of a String variable. I don't mean for comparison, because there we use StringUtils.isEmpty()

Answer

David Pierre picture David Pierre · Nov 4, 2010

Of course not. Do you really think "" is not clear enough ?

Constants have essentially 3 use cases:

  1. Document the meaning of a value (with constant name + javadoc)
  2. Synchronize clients on a common value.
  3. Provide a shortcut to a special value to avoid some init costs

None apply here.