Skip Top Navigation Bar

Mutable vs Immutable Data

Mutable Data

Some examples of mutable data:

Immutable Data

Now, let's discuss immutable data. There are times we would not want data to change during the running of a program. When data that isn't supposed to change is stored in an immutable data type, it makes the data safer.

Some examples of immutable data:

There are classes where the data is immutable. For example, the String class. When you create a String, it is immutable. We will learn more about the String class in section 1.1.D.6 Calling Methods of a Class.

Resources