Sobes.tech
Junior — Middle

Can you explain what the term 'mutable' means in programming?

sobes.tech AI

Answer from AI

In programming, the term "mutable" means that an object or variable can be changed after creation. For example, in Java, objects of the String class are immutable — their contents cannot be changed after creation, whereas objects of the StringBuilder class are mutable, as their contents can be modified.

Example:

StringBuilder sb = new StringBuilder("Hello");
sb.append(" world");
System.out.println(sb.toString()); // Outputs: Hello world

Here, the object sb is modified by adding text, which cannot be done with a regular String.

Can you explain what the term 'mutable' means in… - sobes.tech