Hammad Hassan
Hammad Hassan

Reputation: 1222

Serialization Concept In Java with Composition

If an object is going to be serialized will it be possible to serialize its data member(which are also objects that is composition).
If yes then in which order the state of those objects will be retrieved?

Upvotes: 3

Views: 582

Answers (1)

A4L
A4L

Reputation: 17595

If they are also Serializable then, yes otherwise you'll get a NotSerializableException. If you explicitly want to not serialize a member object then declare it as transient.

Regarding the order, I don't get what you mean by that. If you read a serialized object you'll get it in the exact same state it had at serialization.

Upvotes: 1

Related Questions