用“immutable object”造句大全,immutable object造句
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.
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.
If you have an immutable object, you must set whatever state it will contain in the constructor.
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.