I'm a little confused about serialization.
I have a class, lets call it Container. Variables of the Container class contain ArrayLists of other classes - A,B,C,etc...
If I were to serialize and save Container, would I then, after reading it back in (and, for clarity, I understand how to do that part) have access to those same instances of classes A,B,etc or do they need to be separately serialized? Further, do A,B,etc need to implement Serializable is it that covered by Container doing so?
Thanks in advance
This depends on how the Collection you are using is serialised.
If you are using an ArrayList then it will serialise all the items in the List.
In order to serialise the contents, the contents need to implement Serializable aswell otherwise they need to be marked transient.
So, to answer your two questions:
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