“immutable object”可以造什么句,immutable object造句
来源:语文精选馆 2W
If you have an immutable object, you must set whatever state it will contain in the constructor.
So as long as you stick to the simplest rules of concurrent programming - stateless services and immutable objects, it will be a breeze to wire your services to any producer or consumer.
An immutable object's state cannot change after construction. In other words, the constructor is the only way you can mutate the object's state.
If you want to change an immutable object, you don't - you create a new object with the changed value and point your reference to it.