How to model cycles between immutable class instances?
问题 Immutable classes are great but there is one big problem i cant think of a sensible way to solve - cycles. class Friend { Set<Friend> friends(); } How does one model Me having You as a friend who in turn has me as a Friend back ? IMMUTABILITY This class from the outside world should definitely be immutable. The value held internally should be constant for the purposes of equality checks. 回答1: [[[ Edit: Added code to demonstrate fully immutable concept ]]] That's why builders are so nice for