473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

what is Serializable...

77
can any one explain what is serializable..
Thanks,
P.Jerald
Nov 20 '07 #1
9 1969
r035198x
13,262 8TB
can any one explain what is serializable..
Thanks,
P.Jerald
What do the books say?
Nov 20 '07 #2
heat84
118 100+
Serializable is an interface in Java which is implemented by classes that will be having code that will read or write an object into bits that can be stored on disk or can be sent over the network. Where exactly do you need clarity?
Nov 20 '07 #3
pjerald
77
Serializable is an interface in Java which is implemented by classes that will be having code that will read or write an object into bits that can be stored on disk or can be sent over the network. Where exactly do you need clarity?
Thanks r035198x and heat84, This quote gets me some idea.
But i don understand the following...

Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

Thanks,
P.Jerald.
Nov 20 '07 #4
r035198x
13,262 8TB
Thanks r035198x and heat84, This quote gets me some idea.
But i don understand the following...

Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

Thanks,
P.Jerald.
Objects can be serialized if their classes or super classes were specified as implementing the serializable interface. Which part do you not understand there then?
Nov 20 '07 #5
pjerald
77
Actually what i am trying to know the term "serialize"..

"Objects are serialized with the ObjectOutputStream and they are deserialized with the ObjectInputStream."

And what the above says..
Thanks,
P.Jerald
Nov 20 '07 #6
heat84
118 100+
Actually what i am trying to know the term "serialize"..

"Objects are serialized with the ObjectOutputStream and they are deserialized with the ObjectInputStream."

And what the above says..
Thanks,
P.Jerald
Do you then understand Java IO and how the streams work?
Nov 20 '07 #7
chaarmann
785 Expert 512MB
Actually what i am trying to know the term "serialize"..

"Objects are serialized with the ObjectOutputStream and they are deserialized with the ObjectInputStream."

And what the above says..
Thanks,
P.Jerald
"Serializable" means you can save and load the whole object, for example to a file on a disk, or to a database, with just a single command and without going into its internals.
"Stream" means, you save or load the data to a disk, to a database or to whatever external device you want. It depends on the type of stream.

For example you have an object that stands for a company. Inside you have a list of employees and a list of rooms. Each employee is an object that has a name, salary, etc.. Each room consists of a list of furnitures. So you see you have a rather complex object. Without serialization, you must loop through the data of your company object and save all the employees, rooms etc., one by one. And when saving an employee, you must write code to save its name, salary etc.. You would do that in some hundred lines of code. And whenever your structure changes, you have to rewrite your code. But with serialization (that means if all components implement the serialized interface), you can save the whole structure with a single command. You can also read an object with a single command.
No need anymore to write all these lines of code. If your structure changes, no need to change any single line regarding saving or loading. But there is one drawback: if your structure changes, you cannot read an old object into a new structure. Usually you read in an old object and copy the data over into a new object.
Nov 20 '07 #8
r035198x
13,262 8TB
"Serializable" means you can save and load the whole object, for example to a file on a disk, or to a database, with just a single command and without going into its internals.
"Stream" means, you save or load the data to a disk, to a database or to whatever external device you want. It depends on the type of stream.

For example you have an object that stands for a company. Inside you have a list of employees and a list of rooms. Each employee is an object that has a name, salary, etc.. Each room consists of a list of furnitures. So you see you have a rather complex object. Without serialization, you must loop through the data of your company object and save all the employees, rooms etc., one by one. And when saving an employee, you must write code to save its name, salary etc.. You would do that in some hundred lines of code. And whenever your structure changes, you have to rewrite your code. But with serialization (that means if all components implement the serialized interface), you can save the whole structure with a single command. You can also read an object with a single command.
No need anymore to write all these lines of code. If your structure changes, no need to change any single line regarding saving or loading. But there is one drawback: if your structure changes, you cannot read an old object into a new structure. Usually you read in an old object and copy the data over into a new object.
Serialization simply means writing an object's state to a squence of bytes (and reading those bytes later into an object).
The main benefit is actually that objects can persist in memory even after the program(or VM) terminates.
Nov 20 '07 #9
pjerald
77
Serialization simply means writing an object's state to a squence of bytes (and reading those bytes later into an object).
The main benefit is actually that objects can persist in memory even after the program(or VM) terminates.
Thanks, chaarmann,heat84 and r035198x. Thanks a lot.
regards,
P.Jerald.
Nov 20 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: xmail123 | last post by:
Hi, Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
5
by: Ben Terry | last post by:
I get the following compilation error: "The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)" Can anyone tell me why the...
2
by: Prakash | last post by:
Hi Friends, In my C# application, i have tried to serialize some structured data using Soapformatter. While calling the serialize funciton i got the exception message like "mscorlib....The...
1
by: cpnet | last post by:
I have a DataTable defined in a strongly-typed DataSet: public class MyDataSet: DataSet... { ... public class MyDataTable: DataTable... { ...}
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.