Normally, objects do not persist beyond the lifetime of the program that created them.
However, persistence is required when we write objects to a file to be later read back in, possibly
by a different program. Although we have seen how to read and write primitive data types and
text to a file, we require a mechanism for storing the state of an object. Serialization converts an
object and its state to a stream of bytes. RMI (Remote Method Invocation) also uses serialization
to transparently communicate with objects on remote machines.
The JVM automatically handles most
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.