What is serializable in Java?

Source: Internet
Author: User

An object-serialized interface in which the object of a class is serializable only if it implements the serializable interface. So if you want to serialize objects of some classes, these classes must implement the Serializable interface. In fact, serializable is an empty interface with no specific content, and its purpose is simply to identify the object of a class that can be serialized.

Under what circumstances you need to serialize a when you want to write an object in memory to the hard disk; b when you want to use sockets to transfer objects over the
network;
c. When you want to transfer objects via RMI;
explain it a little bit: a. For example, your memory is not enough, the computer will be part of the memory of the object temporarily saved to the hard disk, waiting to be used when read into memory, the hard disk that part of the storage space is called virtual memory. For example, if you want to save a particular object to a file, and I'm using it every few days, then it's time to implement the Serializable interface;
B. In Java socket programming, you may sometimes want to transfer a class of objects, Then it is also necessary to implement the serializable interface; The most common is that you transmit a string, which is the class within the JDK and implements the serializable interface, so it can be transmitted over the network.
c If you want to invoke the method of a remote object via a remote method call (RMI), if you call a method of another computer B's object in Computer A, you need to implement a serialization interface by getting a reference to the computer B target object from the Jndi service, and transferring the object from B to a.
no one says anything that can be accurate, critical 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.