To make a class serializable we do the following:
class A implements Serializable {
transient Object a;
}
And not this:
serializable class A {
transient Object a;
}
Why, if we want to make a class serializable, do we implement a special interface. And if we want to exclude some fields we use the keyword transient
?
Why aren't special keywords used in both cases? I mean were there any reasons to make the same thing in different ways? I know, there is no such keyword as serializable
but why wasn't it introduced instead of the special interface Serializable
?
Serializable
. – GarikSerializable
interface does seem like magic (which is not the same as magic numbers, btw). – PomanderSerializable
feels grafted on to the language. And I think the answer is because it is. – Peertransient
keyword into the first edition of the language but didn't activate it until they addedSerializable
in 1.1. – Peer