To make a class serializable we do the following:
class A implements Serializable {
transient Object a;
}
And not this:
Serializable
is a marker interface. Interfaces are a standard way (in Java and in some other languages) of indicating features of a class; an "is a" relaionship. Making Serializable
an interface means we can declare methods that accept or return Serializable
s just like we can methods that work with other interfaces. Anything else would have required syntax changes to the language (at the time; now we have annotations, but I think an interface would still be used).