If immutable objects1 are good, simple, and offer benefits in concurrent programming why do programmers keep creating mutable objects2?
I have four years of experience in Java programming and as I see it, the first thing people do after creating a class is generate getters and setters in the IDE (thus making it mutable). Is there a lack of awareness or can we get away with using mutable objects in most scenarios?
An immutable object is an object whose state cannot be modified after it is created.
A mutable object is an object which can be modified after it is created.