In Java, What Is serializable?

Source: Internet
Author: User
Tags object serialization

An object serialization interface. A class can be serialized only when the serializable interface is implemented. Therefore, to serialize objects of some classes, these classes must implement the serializable interface. In fact, serializable is an empty interface with no specific content. Its purpose is simply to identify a class object that can be serialized.

When serialization is required
A) when you want to write the objects in the memory to the hard disk;
B) when you want to use a socket to transmit objects over the network;
C) when you want to transmit objects through RMI;
A) For example, if your memory is insufficient, the computer will temporarily save some objects in the memory to the hard disk and then read them into the memory when they are used, the storage space of the hard disk is the so-called virtual memory. For example, if you want to save a specific object to a file and I will use it several days later, you need to implement the serializable interface;
B) During Java socket programming, you may sometimes want to transmit a certain type of objects, so you also need to implement the serializable interface; the most common is that you transmit a string, it is a class in JDK and also implements the serializable interface, so it can be transmitted over the network.
C) if you want to call a method of a remote object through remote method call (RMI), such as calling the method of an object of another computer B in computer, then you need to get the reference of the target object of computer B through the JNDI service, and transfer the object from B to A, you need to implement the serialization interface.
No one can give a complete and accurate reference.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.