Why is there no String.Empty in Java?

前端 未结 12 1449
悲哀的现实
悲哀的现实 2020-12-07 15:11

I understand that every time I type the string literal \"\", the same String object is referenced in the string pool.

But why doesn\'t the String API in

12条回答
  •  猫巷女王i
    2020-12-07 15:41

    I understand that every time I type the String literal "", the same String object is referenced in the String pool.
    There's no such guarantee made. And you can't rely on it in your application, it's completely up to jvm to decide.

    or did the language creators simply not share my views?
    Yep. To me, it seems very low priority thing.

提交回复
热议问题