Serializable in java [duplicate]
Possible Duplicate:
What is the difference between Serializable and Externalizable in Java?
What is the difference between Serializable
and Externalizable
interface?
Serializable allows an object to be written out in a standard format; there's some control over part of the process, but mostly it's automatic. Externalizable provides much more complete control (e.g., allowing an object that is a table of numbers to be written out as CSV-format data).
Serializable doesn't require you to write any methods (though it might be a good idea) since it is a marker interface. Externalizable requires the writing of methods.
Serializability of a class is enabled by the class implementing the java.io.Serializable
interface. Classes that do not implement this interface will not have any of their state serialized or deserialized.
Externalizable Only the identity of the class of an Externalizable instance is written in the serialization stream and it is the responsibility of the class to save and restore the contents of its instances.
精彩评论