+ 3

How do you create an Immutable class like String

Immutable class objects can not be modified

2nd Mar 2017, 8:12 AM
harish swami
harish swami - avatar
2 Answers
When an object is mutable, attributes are defined when they are created, and never changed after that. Hide instance variables from outside and omit any method that modifies them. Concrete ways are varied among languages.
2nd Mar 2017, 9:44 AM
Twelfty - avatar
final class Immutable {}
24th Apr 2017, 12:58 PM
Mike Mather
Mike Mather - avatar