What is a reason for having strings be immutable?

Strings will never get a race condition because of corruption. Immutable classes are easier to design, implement and use than mutable classes. They are less prone to error and are more secure. An immutable object can be in exactly one state, the state in which it was created.

No comments:

Post a Comment