We sometimes convert a Java object into a byte stream or restore it to a Java object from a byte stream. For example, to store Java objects to hard disks or transmit them to other computers on the network, we can write this process by ourselves.CodeTo convert a Java object into a byte stream of a certain format for re-transmission. However, JRE itself provides this support. We can call the writeobject method of outputstream to do this, if you want Java to help us, the object to be transmitted must implement the serializable interface, so that special processing will be performed during javac compilation, and the compiled class can be operated by the writeobject method, this is the so-called serialization. The class to be serialized must implement the serializable interface, which is a mini interface with no implementation method, implements
Serializable is only used to indicate that the object can be serialized.
For example, in web development, if an object is stored in a session, Tomcat will serialize the session object to the hard disk during restart, and the object must implement the serializable interface. If the object needs to be transmitted over the network or remotely called through RMI in the distributed system, the object needs to be transmitted over the network, and the transmitted object must implement the serializable interface.