What is strings mutability and immutability?

Technology CommunityCategory: StringsWhat is strings mutability and immutability?
VietMX Staff asked 3 years ago

Strings can either be mutable or immutable.

  • When a string is immutable it means that it’s fixed allocated. So your string it’s unique and can’t be modified. If you change it, a copy of that string is created and the original string is deallocated instead.
  • When a string is mutable it means that it’s dynamically allocated, so your string can be modified.