Hi cowboys,
Hans Beck�rus wrote:
" ... Note also that while the collection interface are not serializable, the concrete collection classes in the Java API are."
What confuses me a little is the last sentence.
Say, you have a serializable class containing this member:
Then you can serialize objects of that class. That's because the object type of
list is ArrayList, which is serializable. It is not important here that the reference type is List, which is not serializable.
However when you have a class like
... it is not possible to use a Banana object as a member in a serializable class.
Unless you mark it
transient.
I think, that's all K&B wanted to express with this sentence.
Considering arrays:
I find arrays a bit confusing when it comes to serialization.
e.g.
prints out:
oneObject is Serializable? false
objectArray is Serializable? true
So, an array always IS-A Serializable.
But when you have an array of non-serializable objects as a member in your class (implementing Serializable), you cannot serialize it. Famous NotSerializableException.
An array generally is serializable and it's up to you to see that all elements in the array are objects of classes that implement Serializable.
Yours,
Bu.