Computer Science, asked by vstthakur0947, 8 months ago

what do you understand by term immutable​

Answers

Answered by suridhirimza
3

Answer:

Hope it's helpful

Explanation:

Immutable means that once the constructor for an object has completed execution that instance can't be altered.

This is useful as it means you can pass references to the object around, without worrying that someone else is going to change its contents. Especially when dealing with concurrency, there are no locking issues with objects that never change

e.g.

class Foo

{

private final String myvar;

public Foo(final String initialValue)

{

this.myvar = initialValue;

}

public String getValue()

{

return this.myvar;

}

}

Similar questions