In simple terms, serialization is used to store an object (all relevant 
data members in that object) to a disk file. Deserialization is used to 
retrieve such data from a  disk file to RAM object of our program. 
Advantage of serialization may not be evident if all the data members of 
the object to be saved on to disk are of basic data types. Serialization 
becomes convenient when the object contains objects of other classes as 
data members.
For example, consider that you are using classes A, B, C. The class A has 
data members-
    int i1;
    B b1;
    C c1;
The class B has data members-
    String name, surname;
     int roll_num;
The class C has data members-
     int roll_num;
     int age;
     double height;
etc.
Assume that using some mutator methods in class A, you have initialized the 
data members to some specific values. Now if you want to store this data 
(of object of class A) to a disk file (for future use), and you go 
member-by-member, you will have to write many lines of code. Notice that b1 
and c1 contain only the references (pointers/addresses) and not the actual 
objects. So, your code will have to take care of data members of b1 and c1 
also. With serialization feature of Java, you can save the object (of class 
A) by writing only one line of code. Of course, code lines for opening of 
file etc. would be there.
Similar advantage is available during retrieval using the de-serialization 
feature.
In stead of saving to disk file, you may need the data to be sent over net; 
same advantage of 'less coding' !



On Sunday, 13 January 2013 13:10:54 UTC+5:30, anush karthi wrote:
>
> What is java serialization 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-code/-/Mvy-vBeHUKoJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to