Serialization of static inner class

inner-classes, java, serialization

Solution

A static inner class is no different than a top-level class in this respect: it can be serialized if it is declared to implement `Serializable` (or is a subclass of a class declared to implement `Serializable`). Also, as with top-level classes, all objects encountered during serialization at run time must be serializable to avoid a `NotSerializableException`. Since the inner class is `static`, the nature of the outer class is irrelevant to this.

Problem

Can we serialize a static inner class in Java? The class itself is declared as static here.

Original source