I\'ve been mulling this over & reading but can find an absolute authoritative answer.
I have several deep data structures made up of objects containing ArrayLists, S
Do NOT use java.util.Vector
, use java.util.Collections.unmodifiableXXX()
wrapper if they truly are unmodifiable, this will guarantee they won't change, and will enforce that contract. If they are going to be modified, then use java.util.Collections.syncronizedXXX()
. But that only guarantees internal thread safety. Making the variables final
will also help the compiler/JIT with optimizations.