serializable
Last updated
Was this helpful?
Last updated
Was this helpful?
Serializable is a marker interface in Java. It is used to indicate that a class can be serialized, which means its state can be converted into a byte stream. Serialization is the process of converting an object's state into a format that can be stored or transmitted and later deserialized back into an object.To make a class serializable, it needs to implement the Serializable interface. This interface acts as a flag to the Java runtime that the class can be serialized. It is a marker interface because it does not contain any methods or fields to implement.When a class implements Serializable, all of its subtypes are also considered serializable.However, if a class has a reference to another object, both the class and the referenced object must implement Serializable, or else a NotSerializableException will be thrown.