How do you create an Immutable class like String | Sololearn: Learn to code for FREE!
Nowy kurs! Każdy programista powinien nauczyć się Generative AI!
Wypróbuj darmową lekcję
+ 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 odpowiedzi
0
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
Twelfty - avatar
0
final class Immutable {}
24th Apr 2017, 12:58 PM
Mike Mather
Mike Mather - avatar