Hmm, but if I have say a POJO with a list that I d...
# announcements
f
Hmm, but if I have say a POJO with a list that I dont want anyone to tamper with, I just want to be able to read it from outside, not modify it in any way. I can then use a backing field and just give the
List<>
to anyone asking. But if that client calls
.toMutableList()
on it, has it then effectively overriden that? I guess it cant modify the list, like add new stuff to it etc, but it can still mess up the content right? But I guess
.toMutable
is not even needed for that. Hmm, I just want to make sure I dont fuck myself over in the future xD reference types bugs can be so damn confusing, Im looking to get rid of as much as possible.