Why Wrapper class like Boolean in java is immutable?

前端 未结 4 2141
无人及你
无人及你 2021-01-05 15:23

I can\'t see the reason why the Boolean wrapper classes were made Immutable.

Why the Boolean Wrapper was not implemented like MutableBoolean in Commons lang which a

4条回答
  •  心在旅途
    2021-01-05 15:37

    Patashu is the closest. Many of the goofy design choices in Java were because of the limitations of how they implemented a VM. I think originally they tried to make a VM for C or C++ but it was too hard (impossible?) so made this other, similar language. Write one, run everywhere! Any computer sciency justification like those other dudes spout is just after-the-fact folderal. As you now know, Java and C# are evolving to be as powerful as C. Sure, they were cleaner. Ought to be for languages designed decade(s) later! Simple trick is to make a "holder" class. Or use a closure nowadays! Maybe Java is evolving into JavaScript. LOL.

提交回复
热议问题