When should we implement Serializable interface?

  1. From What’s this “serialization” thing all about?:

    It lets you take an object or group of
    objects, put them on a disk or send
    them through a wire or wireless
    transport mechanism, then later,
    perhaps on another computer, reverse
    the process: resurrect the original
    object(s). The basic mechanisms are to
    flatten object(s) into a
    one-dimensional stream of bits, and to
    turn that stream of bits back into the
    original object(s).

    Like the Transporter on Star Trek,
    it’s all about taking something
    complicated and turning it into a flat
    sequence of 1s and 0s, then taking
    that sequence of 1s and 0s (possibly
    at another place, possibly at another
    time) and reconstructing the original
    complicated “something.”

    So, implement the Serializable interface when you need to store a copy of the object, send them to another process which runs on the same system or over the network.

  2. Because you want to store or send an object.

  3. It makes storing and sending objects easy. It has nothing to do with security.

Leave a Comment