For example consider the code below
List<Reference> references = context.getReferences()
.stream()
.filter(ref -> ref.getCondition() == SOMETHING_DESIRABLE)
.collect(Collectors.toList());
Now if I mutate each reference inside references
list, will it be reflected inside the original context.references
?
There is no general way to clone objects in Java.
It would be fundamentally impossible for it to automatically return different instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With