Fiveable
Fiveable

Immutable

Definition

Immutable refers to an object or data structure that cannot be changed after it is created. Once created, its state remains constant throughout its lifetime.

Analogy

Imagine an unchangeable tattoo on your arm. Once it's inked onto your skin, you can't modify or erase it. It stays the same forever, just like immutable objects remain unchanged once they're created.

Related terms

Mutable: This term describes objects or data structures that can be modified after creation. Unlike immutable objects, mutable ones can have their state altered.

Final Keyword: In Java programming language, using the "final" keyword makes variables constant and classes uninheritable. It ensures immutability and prevents modification.

String Class: Strings in many programming languages are often immutable objects by default. Any modifications to strings create new string objects rather than modifying existing ones.

"Immutable" appears in:



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.