Is StringUtils.EMPTY recommended?

后端 未结 11 1932
情深已故
情深已故 2020-12-08 01:46

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

11条回答
  •  隐瞒了意图╮
    2020-12-08 02:08

    Yes, it makes sense. It might not be the only way to go but I can see very little in the way of saying this "doesn't make sense".

    In my opinion:

    • It stands out more than "".
    • It explains that you meant empty, and that blank will likely not do.
    • It will still require changing everywhere if you don't define your own variable and use it in multiple places.
    • If you don't allow free string literals in code then this helps.

提交回复
热议问题