Serializable and Parcelable differences

Source: Internet
Author: User
Tags object serialization

Http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0204/2410.html

Http://www.cnblogs.com/blueofsky/archive/2012/01/07/2315664.html

Http://www.2cto.com/kf/201403/288476.html

What is serialization and deserialization? (1) noun explanation

Serialization of objects: the process of converting a Java object into a sequence of bytes and storing it in a storage medium.
Deserialization of objects: the process of reverting a sequence of bytes to a Java object.

(2) Detailed interpretation of serialization

Serialization of objects involves three point keys: Java objects, byte sequences, storage.

1. What is the composition of the Java object?
Java objects contain variables and methods. But sequence and deserialization only handle Java variables without processing methods, and the sequence and deserialization only process the data.

2. What is a character sequence?
The character sequence is two words, the character is in the computer and telecommunication field, the character (Character) is an information unit. Mathematically, a sequence is an object (or event) that is lined up in a column.
Character-Wikipedia, sequence-wikipedia is plainly a collection of multiple characters that are consecutively arranged. Similar to 1a165613246546

3. Storage
Character sequences need to be saved to a place, either a hard disk or a memory.
The simple argument is that serialization saves the current object information. Deserializes exactly the opposite operation.


Second, what is the difference between a Java object and a Java object serialization?

The premise of the existence of a Java object must exist during the JVM's run, and if you want to get the specified Java object in a non-running JVM or on another machine JVM, it cannot be done under the existing Java object mechanism.
Unlike Java objects, if you are serializing a Java object because the principle is to save the Java object information to the storage medium, you can still use the Java object in two cases where the Java object above cannot exist.


Third, why use serialization, deserialization?

Based on the above understanding of serialization, deserialization, this question can be translated into, why need to save the object information in the storage medium and then read it?
Because of the explanation in the second, there is a need to acquire the specified Java object in the case of a JVM that is not running, or on other machine JVMs.


Iv. What is the difference between serializable and parcelable in Android?

Both are used to support serialization, deserialization, the biggest difference between the storage medium is different, serializable use IO Read and write storage on the hard disk, and parcelable is directly in memory read and write, it is obvious that the memory read and write speed is usually greater than IO read and write, Therefore, parcelable is usually preferred in Android.
Serializable is not the focus of current attention, but you can view the Java serialization algorithm dialysis article to implement a simple serializable example, view the serialized IO file, and read the meaning of each 16-digit number in 16-binary format.

Serializable and Parcelable differences

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.