Serializable in Java

Source: Internet
Author: User
Tags object serialization
In Java, serializable is an interface for object serialization, where a class can only implement the Serializable interface, and its objects are serializable. Therefore, if you want to serialize objects of some classes, these classes must implement the Serializable interface. In fact, serializable is an empty interface, nothing specific, its purpose is simply to identify a class of objects can be serialized.


A) When you want to write an object in memory to the hard disk;
b) When you want to use sockets to transfer objects on the network;
c) When you want to transfer objects through RMI;

To explain a little bit more:
A) For example, your memory is not enough, the computer will be a part of the memory of the object temporarily saved to the hard disk, and then to use the time to read into the memory, the hard disk that part of the storage space is called virtual memory. In the case of you want to save a particular object to a file, I take it out every few days, then the implementation of the Serializable interface;
b) In the Java socket programming, you may sometimes want to transfer a certain class of objects, then also implement the serializable interface; the most common you transmit a string, it is the class inside the JDK, also implements the Serializable interface, So it can be transmitted over the network.
c) If you want to invoke a method of a remote object through a remote method call (RMI), such as a method of invoking another Computer B object in Computer A, you need to implement the serialization interface by obtaining a reference to the computer B target object through the Jndi service and transferring the object from B to a.
No one's words can be all accurate, critical reference.



Serializable in Java

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.