O'Reilly logo

Component Development for the Java™ Platform by Stuart Dabbs Halloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.7. Object Graphs

Serialization is recursive. When you serialize an object, all of its serializable fields are also serialized. Primitives are serialized by the DataOutput methods of the stream, and objects are serialized by writeObject. This fact is implicit in the Person example of this chapter, since lastName and firstName are themselves object types, not primitives. Recursion to referenced objects is highly desirable because it simplifies serializing complex graphs of objects all in one step. However, the fact that writeObject actually serializes an entire graph of objects introduces a few wrinkles that you need to be aware of.

The first issue is the danger of serializing far more data than you wanted. Consider a data object that lives inside ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required